View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ken McLennan[_4_] Ken McLennan[_4_] is offline
external usenet poster
 
Posts: 29
Default Remove characters from string

G'day there Ron,

Here's a routine, using regular expressions, that will extract the Time and the
a or the p.

It works on your examples.


Then it will more than likely work on the real data, too.

However, if there were a number preceding the time that was not a time, it
would have to be modified.


I can do a bit of 'pre-cleaning' to, hopefully, alleviate such a
thing.

It will return the existing time string and, if present in the original, an "a"
or a "p".


That's what I'm after. If there's no "a" or "p" it's not a problem
as long as the string on the other side of the hyphen has one. I've
already written code that calculates the correct letter from what's on
the other side. It's a bit clumsy, but it works so I'm not gonna touch
it <g.

If some of the entries in your data differ significantly from what you've
posted, small changes in the "regex" may be required.


Nodnodnod. I'll give it a try tonight. The first half (before the
hyphen) is not a problem as there are no code letters introduced
adjacent to the hyphen (thank the Gods for small mercies). In one small
aspect over which I have some control, I've requested (don't have
authority to TELL anyone) that a space be left after the shift ending
time to differentiate between times and any extra characters. I can't
enforce it but I did ask politely =).

Set objRe = CreateObject("vbscript.regexp")


Is that a standard library? I'll have to check after my days off
to see if it's installed. If not then I'm out of luck (dammit!!) Still,
I'll just have to try it and see.

Thanks very much for your help. It's greatly appreciated.

--
See ya,
Ken McLennan
Qld, Australia