Regex

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

Could someone, please, tell me the regex expression to split:

"$String1{Id1}$ | $String2{Id2}$ ( $String3$ )"

Into:

"String1{Id1}", "String2{Id2}" and "String3"

And then "String1{Id1}" into:
"String1", "Id1", ...

Thanks,
Miguel
 
Hi Miguel,

are you sure you need a regular expression to split this string?
why don't you use the String.Split functionality which splits a string into
an array?

Nico
 
are you sure you need a regular expression to split this string?
why don't you use the String.Split functionality which splits a string
into an array?

That's certainly the way I'd do it - I still have trouble getting my head
round regular expressions... :-)
 
Hello,

Could someone, please, tell me the regex expression to split:

"$String1{Id1}$ | $String2{Id2}$ ( $String3$ )"

Into:

"String1{Id1}", "String2{Id2}" and "String3"
(?<=\$)(\w|{|})*?(?=\$)


And then "String1{Id1}" into:
"String1", "Id1", ...

\w*
 

Hi Alexey,

I am trying to do another thing with regex which is similar to these
ones but is not working.

I have:
"Posted by $Author$ @ $DateTime${HH:mm}"

I want to get two strings:
"Posted by $Author$ @ $DateTime$"
And
"HH:mm"

Just two other things:
Should I always use regex for this kind of operation?
Do you know any good resource to learn regex?

Thanks,
Miguel
 
re:
Do you know any good resource to learn regex?

RegEx Library:
http://regexlib.com/

RegEx Tutorial :
http://www.regular-expressions.info/tutorial.html

The 30 minute RegEx Tutorial :
http://www.codeproject.com/dotnet/RegexTutorial.asp

Regular Expressions in .NET :
http://aspnet.4guysfromrolla.com/articles/022603-1.aspx




Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
 
Hi Alexey,

I am trying to do another thing with regex which is similar to these
ones but is not working.

I have:
"Posted by $Author$ @ $DateTime${HH:mm}"

I want to get two strings:
"Posted by $Author$ @ $DateTime$"
And
"HH:mm"

There are many ways to do it, for example

(\w|\s|@|\$|\:)*

It simply does search for all alphanumeric simbols + space + @ + $ and
a colon ':'

because of {} you will get the two strings as requested

Just two other things:
Should I always use regex for this kind of operation?
yes.

Do you know any good resource to learn regex?

www.google.com knows it :-)

Hope it helps
 
Back
Top