Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

RegExp

Posted on 2004-03-29
3
Medium Priority
?
376 Views
Last Modified: 2010-04-05
Hi! may you know the  TRegExpr http://regexpstudio.com/) for Delhpi. So I have a large text file, that have some "UiD ( 12 )" pattern. I need to pick up the number from this string. I know that if I want to get the pattern I need to do a UiD \( [0-9]?. \) rexep search. And if I want to get the number from this pattern, I need to do a [0-9]?. . But can I join somehow this two regexp? I mean the first one give output pattern to the second one, so I get the number itself. pls help me!

0
Comment
Question by:Kosztik
[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
  • 3
3 Comments
 
LVL 17

Accepted Solution

by:
mokule earned 500 total points
ID: 10709315
You should join them like this
"(UiD\(\ )([0-9]?.)(\ \))"
And in Match[1] You should have "UiD( "
in Match[2] - number
and in Match[3] " )"
0
 
LVL 17

Expert Comment

by:mokule
ID: 10709329
Here You've got example from usage articles provided with help to TRegExpr
Example 2
How to extract phone numbers from unformatted text (web-pages, e-mails, etc).
For example, we need only St-Petersburg (Russia) phones (city code 812).

procedure ExtractPhones (const AText : string; APhones : TStrings);
begin
  with TRegExpr.Create do try
     Expression := '(\+\d *)?(\((\d+)\) *)?(\d+(-\d*)*)';
     if Exec (AText) then
      REPEAT
        if Match [3] = '812'

         then APhones.Add (Match [4])
      UNTIL not ExecNext;
    finally Free;
   end;
end;

For the input text

"Hi !
Please call me at work (812)123-4567 or at home +7 (812) 12-345-67
truly yours .."

this procedure returns

APhones[0]='123-4567'

APhones[1]='12-345-67'

0
 
LVL 17

Expert Comment

by:mokule
ID: 10709355
It seems that I lost 1 space. Correct expression according to Your example should be
(UiD\ \(\ )([0-9]?.)(\ \))
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

721 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