?
Solved

Need simple regex

Posted on 2009-05-18
13
Medium Priority
?
335 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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
 
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 150 total points
ID: 24415582
Sorry, leave out the ^:

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

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have been reconstructing a PHP-based application that has grown into a full blown interface system over the last ten years by a developer that has now gone into business for himself building websites. I am not incredibly fond of writing PHP code o…
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…
Suggested Courses

762 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