[Mono-list] C# Regular Expressions Help Urgent

Hugues Lismonde h.li@skynet.be
Thu, 14 Aug 2003 14:42:46 +0200


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

LaVey wrote:

> hi there...
>  
> I am having problems checking the following string...
>  
> string str_Content="The day is <CheckOne> for me <CheckTwo> and so on.. ";
>  
> how do I create a regex pattern that matches my "<CheckOne>" and 
> "<CheckTwo> " within my str_Content in c#?
>  
> regards,
> Nigil
Try:

<CheckOne>|<CheckTwo>

that will give you:
Match 0 = <CheckOne>
Match 1 = <CheckTwo>

or if you want to have more checks:

<([A-Za-z]+)>

with the following result:
Match 0: <CheckOne>, group 1: CheckOne
Match 1: <CheckTwo>, group 1: CheckTwo
...

So that a match will contain the whole block and the group will contain 
its name.

If you are under Windows, you should try this tool: 
http://www.sellsbrothers.com/tools/#regexd

- --
Hugues Lismonde
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/O4PLT/UMb4JTLzoRAidHAJ0WfjG2i9z9ZkfTLxbjTwcdGztydQCfViFr
9GCSSSw5oZlPzPZOG3Btl2c=
=eHU0
-----END PGP SIGNATURE-----