String

S

shapper

Hello,

I have the following string:

MyString = "Posted by $Author$ @ $DateTime${HH:mm}"

I want to create two strings out of the one before:

a = "Posted by $Author$ @ $DateTime$" ... everything outside {}

and

b = "HH:mm" ... everything inside {}

How can I do this?

Thanks,

Miguel
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

shapper said:
Hello,

I have the following string:

MyString = "Posted by $Author$ @ $DateTime${HH:mm}"

I want to create two strings out of the one before:

a = "Posted by $Author$ @ $DateTime$" ... everything outside {}

and

b = "HH:mm" ... everything inside {}

How can I do this?

Thanks,

Miguel

You can use the RegEx.Matches method with a pattern like "^(.+){(.+)}$"
to match the two strings that you mention.

If I would guess what you are trying to do, you actally want to match
"$Author$" and "$DateTime${HH:mm}" and replace them. That can be done
with the RegEx.Replace method with a pattern like
"\$(.+?)\$(?:{(.+?)})?" and a delegate that returns the string to
replace them depending on the match.
 

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
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top