Regular Expression Question

G

Gunady

Anybody know how is the Regular Expression pattern to find text that
begin with [Html: and end with ], like string:
=================================================================
Event Description: [Html:table style="border-width:1px"
cellpadding="3" cellspacing="1"][Html:tr][Html:td] Some Description
[Html:a href="https://name/detail.aspx?id=1"][Html:/a]
etc
=================================================================
I want to extract out string like this:
[Html:table style="border-width:1px" cellpadding="3" cellspacing="1"]
[Html:tr]
[Html:td]
[Html:a href="https://name/detail.aspx?id=1"]
[Html:/a]

Any help?

Regards,
Gunady
 
K

Kevin Spencer

Will the content inside the square brackets possibly include square
brackets? If not, the following simple Regular Expression would work well
for you:

(?i)\[Html:[^\]]+\]

Translated, this means:

1. ("(?i)") The following is case-insensitive.
2. ("\[Html:") A Match begins with the literal "[Html:".
3. (":[^\]]+") This is followed by one or more characters that are NOT ']'.
4. ("\]") This is followed by the character ']'.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.
 
G

Gunady

Thank you very much, I don't think to search any character except ], I
was thinking to validate any character in between.. haha, thank you
again :)

Regards,
Gunady

Kevin said:
Will the content inside the square brackets possibly include square
brackets? If not, the following simple Regular Expression would work well
for you:

(?i)\[Html:[^\]]+\]

Translated, this means:

1. ("(?i)") The following is case-insensitive.
2. ("\[Html:") A Match begins with the literal "[Html:".
3. (":[^\]]+") This is followed by one or more characters that are NOT ']'.
4. ("\]") This is followed by the character ']'.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

A lifetime is made up of
Lots of short moments.

Gunady said:
Anybody know how is the Regular Expression pattern to find text that
begin with [Html: and end with ], like string:
=================================================================
Event Description: [Html:table style="border-width:1px"
cellpadding="3" cellspacing="1"][Html:tr][Html:td] Some Description
[Html:a href="https://name/detail.aspx?id=1"][Html:/a]
etc
=================================================================
I want to extract out string like this:
[Html:table style="border-width:1px" cellpadding="3" cellspacing="1"]
[Html:tr]
[Html:td]
[Html:a href="https://name/detail.aspx?id=1"]
[Html:/a]

Any help?

Regards,
Gunady
 

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

Top