Solved

Need simple regex

Posted on 2009-05-18
13
330 Views
Last Modified: 2012-05-07
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
0
Comment
Question by:SLoBoil
  • 6
  • 4
  • 2
  • +1
13 Comments
 
LVL 27

Expert Comment

by:ddrudik
ID: 24413849
match on ^\D*
trim the ending whitespace that is returned if desired.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24414273
^(\D*)
0
 

Author Comment

by:SLoBoil
ID: 24414509
Neither of those work :(
0
 
LVL 84

Expert Comment

by:ozo
ID: 24414645
How did you use them?
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 24414699
which regex flavour are you using, please post your example also
0
 

Author Comment

by:SLoBoil
ID: 24415118
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?)*}[$1234567890+(]?)
and it returns CB RICHARD ELLIS 12

so i am close.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 27

Expert Comment

by:ddrudik
ID: 24415140
the following would return Reference: and any non-numerics.
Reference: [^0-9]*

Open in new window

0
 
LVL 27

Expert Comment

by:ddrudik
ID: 24415180
Where in QuickFields are you using this regular expression?
0
 

Author Comment

by:SLoBoil
ID: 24415381
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)

0
 
LVL 27

Expert Comment

by:ddrudik
ID: 24415398
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.,:-]
0
 
LVL 27

Expert Comment

by:ddrudik
ID: 24415404
If you want to allow spaces as well:
[^ a-zA-Z0-9.,:-]
0
 

Author Comment

by:SLoBoil
ID: 24415572
Doesn't the  ^   say not any of those characters ?
0
 
LVL 27

Accepted Solution

by:
ddrudik earned 50 total points
ID: 24415582
Sorry, leave out the ^:

Reference: [ a-zA-Z.,:-]*
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

by Batuhan Cetin Regular expression is a language that we use to edit a string or retrieve sub-strings that meets specific rules from a text. A regular expression can be applied to a set of string variables. There are many RegEx engines for u…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now