Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / March 2004

Tip: Looking for answers? Try searching our database.

Need Help With On Regex Expression

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Garibaldi - 25 Mar 2004 20:09 GMT
Folks,

I have a very large text file to parse and I'm thinking
of using a regex.

I need to isolate data bounded by "200~" (200tilde).
The "200~" appears at the start of a line. There can be
one or more lines between each "200~".

This regex, ^(200~), gets the "200~"'s only. I need to
get what's in between. The following is a sample of the
text file in question.

200~012~020000654518~0503012002~0603312002~07DANIEL R
PEOPLES~082773 SMARTYPANTS DRIVE~09MYTOWN NV
89052~12HENDERSON~13NV~1489052~
1910~24blahblah@abc.com~251`
400~0103012002~0200~03REGULAR SAVINGS~04Balance
Forward~051170~071~0810`
200~300~01KATHLEEN C TOOTLES~021`

Any help would be appreciated
Peter J. Veger - 25 Mar 2004 22:33 GMT
Maybe this works:

(?ms)^200~(.*?)(?=^2~00~)

(?ms) sets multiline option ('^' matches the beginning of a line) and
singleline option  ('. ' also matches a newline)
^200~ matches 200~ at the begin of a line
(.*?) matches and captures everything that comes thereafter (a greedy
capturing group)
(?=^200~) until there is another 200~ at the begin of the line (a zero-width
positive lookahead)

I have not tested this but I hope that it gives at least some pointers..

Peter Veger, Best

> Folks,
>
[quoted text clipped - 18 lines]
>
> Any help would be appreciated
Garibaldi - 26 Mar 2004 00:59 GMT
With one change your expression works perfectly. Here's
the working expression:

(?ms)^200~(.*?)(?=^200~)

Thanks very much, Peter.

>-----Original Message-----
>Maybe this works:
[quoted text clipped - 37 lines]
>
>.
Peter J. Veger - 26 Mar 2004 09:37 GMT
Sorry for the typo (it was just before going to bed...)

Sorry also for the wrong name: (.*?) is not 'greedy' but 'lazy'

and I should read my solution as:
find the marker at bol and capture just enough characters to see the next
marker at bol

Peter J. Veger

> With one change your expression works perfectly. Here's
> the working expression:
[quoted text clipped - 50 lines]
> >
> >.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.