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 / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Regular Expression ( [TAG-I] TEXT [TAG-F] )

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Eduardo Luiz - 23 Nov 2006 15:58 GMT
Hi.. need help..

Sample text:

[NF-I]
nnn
nnn
nnn
nnn
nnn
[NF-F]
[BB-I]
nnn
[BB-F]
[BB-I]
nnn
[BB-F]
[BB-I]
nnn
[BB-F]

need get groups.... select return 4 groups.. like =
\[(?<InitialTag>.*)](?<Text>.*)\[(?<FinalTag>.*)]

but code return 1 match
[NF-I]
nnn....
[BB-F]

Thanks!
Eduardo Luiz - 23 Nov 2006 17:08 GMT
help

> Hi.. need help..
>
[quoted text clipped - 26 lines]
>
> Thanks!
Kevin Spencer - 23 Nov 2006 17:46 GMT
(?<=\[(\w\w)-I\])[^\]]+(?=\[\1-F\])

It's hard to determine exactly what your rules are, so I used these:

The opening tag is defined as a left square-bracket followed by 2 word
characters, followed by a hyphen, followed by the character 'I', followed by
a right square-bracket. The closing tag is defined as a left square-bracket,
followed by the same 2 word characters in the opening tag, followed by a
hyphen, followed by the character 'F'. I used a positive look-behind, with a
group around the 2 characters preceding the hyphen, assumed that the
contents between would not contain the left squaare-bracket, and would
consist of at least one character, and a positive look-ahead, referencing
the same group from the positive look-behind. This results in a set of
matches of all characters between the opening and closing tags as I defined
them.

Signature

HTH,

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

Never trust a dunderhead with a blunderbuss.

> Hi.. need help..
>
[quoted text clipped - 26 lines]
>
> Thanks!
Eduardo Luiz - 23 Nov 2006 18:36 GMT
nice nice.. thanks!

im brazilian.. sorry my english..

im found a solution..

\[(?<TagInicial>.*?)](?<Texto>.*?)\[(?<TagFinal>.*?)]

Thanks a lot!

> (?<=\[(\w\w)-I\])[^\]]+(?=\[\1-F\])
>
[quoted text clipped - 51 lines]
>
> > Thanks!- Hide quoted text -- Show quoted text -
Kevin Spencer - 23 Nov 2006 22:11 GMT
You're very welcome. And there is certainly no need to apologize for your
English. The closest language to Portuguese that I can speak is Spanish, and
I'm not very good at that! And other than Spanish, I'm afraid English is the
only language I speak. The important thing is, we communicated successfully.

:-)

Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com

Never trust a dunderhead with a blunderbuss.

> nice nice.. thanks!
>
[quoted text clipped - 65 lines]
>>
>> > Thanks!- Hide quoted text -- Show quoted text -

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.