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

  • Thread starter Thread starter Eduardo Luiz
  • Start date Start date
E

Eduardo Luiz

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!
 
(?<=\[(\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.

--
HTH,

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

Never trust a dunderhead with a blunderbuss.
 
nice nice.. thanks!

im brazilian.. sorry my english..

im found a solution..

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

Thanks a lot!


(?<=\[(\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.

--
HTH,

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

Never trust a dunderhead with a blunderbuss.



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!- Hide quoted text -- Show quoted text -
 
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.


Eduardo Luiz said:
nice nice.. thanks!

im brazilian.. sorry my english..

im found a solution..

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

Thanks a lot!


(?<=\[(\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.

--
HTH,

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

Never trust a dunderhead with a blunderbuss.

message

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!- Hide quoted text -- Show quoted text -
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top