Regex

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
 
N

Nico Ploner

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
 
M

Mark Rae

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... :)
 
G

Guest

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*
 
S

shapper


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
 
G

Guest

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
 

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

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top