SLoBoil
asked on
Need simple regex
I need a regular expression that basically stops when it encounters a numeric in the string.
For Example:
String: CB RICHARD ELLIS 12/06
RegEx should return: CB RICHARD ELLIS
String: Maritime Telecoms 2ND Lien 5/06
RegEx should return: Maritime Telecoms
For Example:
String: CB RICHARD ELLIS 12/06
RegEx should return: CB RICHARD ELLIS
String: Maritime Telecoms 2ND Lien 5/06
RegEx should return: Maritime Telecoms
^(\D*)
ASKER
Neither of those work :(
How did you use them?
which regex flavour are you using, please post your example also
ASKER
I'm actually using an optical scanning tool called Quick Fields. It is part of the Laserfiche product.
Basically I am scanning a tif image that has a text line like either of the following:
Sample1:
Reference: MARITIME TELECOMMS 2ND LIEN 5/06
Sample2:
Reference: CB RICHARD ELLIS 12/06
For Sample1 I need a regEx that returns just MARITIME TELECOMMS
For Sample2 I need a regEx that returns just CB RICHARD ELLIS
I current have this:
(Reference[:,]\b+{(\a+\b?) *}[$123456 7890+(]?)
and it returns CB RICHARD ELLIS 12
so i am close.
Basically I am scanning a tif image that has a text line like either of the following:
Sample1:
Reference: MARITIME TELECOMMS 2ND LIEN 5/06
Sample2:
Reference: CB RICHARD ELLIS 12/06
For Sample1 I need a regEx that returns just MARITIME TELECOMMS
For Sample2 I need a regEx that returns just CB RICHARD ELLIS
I current have this:
(Reference[:,]\b+{(\a+\b?)
and it returns CB RICHARD ELLIS 12
so i am close.
the following would return Reference: and any non-numerics.
Reference: [^0-9]*
Where in QuickFields are you using this regular expression?
ASKER
Thanks ddrudik, the following is very close
Reference: [^0-9]*
Is there something I could add to it that would also ignore special characters (windows characters that is)
Reference: [^0-9]*
Is there something I could add to it that would also ignore special characters (windows characters that is)
You could just define the set of characters you want to allow and include them in the [^...] block in the pattern such as:
[^a-zA-Z0-9.,:-]
[^a-zA-Z0-9.,:-]
If you want to allow spaces as well:
[^ a-zA-Z0-9.,:-]
[^ a-zA-Z0-9.,:-]
ASKER
Doesn't the ^ say not any of those characters ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
trim the ending whitespace that is returned if desired.