Using Regex to get a block of text 
Author Message
 Using Regex to get a block of text

Good day every one:

I'm trying to get a bolck of text from a plain text file (.txt) using Regex,
the problem I'm having is, that the block of text I want is more than one
line of text, plus I don't really know how many rows there are in the block.
For example:

I'm tring to get everything between the rows that start with the "*03" and
end with the word "End*" here is an example of the file...

*03 blah blah blah blah blah blah blah blah
                             blah blah blah blah blah
                             blah blah blah blah blah
         blah blah blah End*

Some more text goes here .............

*03 blah blah blah blah blah blah blah blah
                  blah blah blah blah blah
                  blah blah blah blah End*

More text .................

*03 blah blah blah blah blah blah blah blah
            blah End*

How can I read these three blocks INCLUDING CR y LF?

I'm trying something like this, but it is not working...

mc = Regex.Matches(source, "\*03.+(?=End\*)")

Thanks in advance for all your help



Wed, 07 Dec 2005 03:59:51 GMT  
 Using Regex to get a block of text


Quote:
> Good day every one:

> I'm trying to get a bolck of text from a plain text file (.txt)
> using Regex, the problem I'm having is, that the block of text I
> want is more than one line of text, plus I don't really know how
> many rows there are in the block. For example:

> I'm tring to get everything between the rows that start with the
> "*03" and end with the word "End*" here is an example of the
> file...

> *03 blah blah blah blah blah blah blah blah
>                              blah blah blah blah blah
>                              blah blah blah blah blah
>          blah blah blah End*

> Some more text goes here .............

> *03 blah blah blah blah blah blah blah blah
>                   blah blah blah blah blah
>                   blah blah blah blah End*

> More text .................

> *03 blah blah blah blah blah blah blah blah
>             blah End*

> How can I read these three blocks INCLUDING CR y LF?

> I'm trying something like this, but it is not working...

> mc = Regex.Matches(source, "\*03.+(?=End\*)")

Jesus,

mc = Regex.Matches(source, "\*03.+?End\*", RegexOptions.Singleline)

Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/



Thu, 08 Dec 2005 18:46:12 GMT  
 Using Regex to get a block of text
Thank you so much Chris it work just great!

Jesus



Quote:


> > Good day every one:

> > I'm trying to get a bolck of text from a plain text file (.txt)
> > using Regex, the problem I'm having is, that the block of text I
> > want is more than one line of text, plus I don't really know how
> > many rows there are in the block. For example:

> > I'm tring to get everything between the rows that start with the
> > "*03" and end with the word "End*" here is an example of the
> > file...

> > *03 blah blah blah blah blah blah blah blah
> >                              blah blah blah blah blah
> >                              blah blah blah blah blah
> >          blah blah blah End*

> > Some more text goes here .............

> > *03 blah blah blah blah blah blah blah blah
> >                   blah blah blah blah blah
> >                   blah blah blah blah End*

> > More text .................

> > *03 blah blah blah blah blah blah blah blah
> >             blah End*

> > How can I read these three blocks INCLUDING CR y LF?

> > I'm trying something like this, but it is not working...

> > mc = Regex.Matches(source, "\*03.+(?=End\*)")

> Jesus,

> mc = Regex.Matches(source, "\*03.+?End\*", RegexOptions.Singleline)

> Hope this helps.

> Chris.
> -------------
> C.R. Timmons Consulting, Inc.
> http://www.crtimmonsinc.com/



Sat, 10 Dec 2005 00:51:49 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Using the RegEx Classes to replace text really fast

2. RegEx to capture script blocks?

3. How to split URL without http:// using RegEx?

4. Need assistance with using RegEx in VB.NET

5. Using RegEx with a Hash based collection

6. Regex using [\w|W]* for everything

7. Filename pattern matching using regex

8. Using VBScript 5.1 RegEx object in VB6?

9. need help with Regex Expression using VB6

10. Getting text source of message using VB/VBA

11. Getting access with VBA to a blocked attachment

 

 
Powered by phpBB® Forum Software