Regular Expression

G

Guest

Thank you in advance. I have a string that is variable length. Every
five characters I need to put a "<BR>" in. So if I have the following:

Dim Test as string = "xxxxxxxxxxxxxxxxx"

I need to get "xxxxx<BR>xxxxx<BR>xxxxx<BR>xx". I think a regular
expression would work for this. Now this problem: I have never done one
before. How would I go about doing this. I am using notepad as the
editor.

Thanks again.
 
K

Karl Seguin

Note sure that regex is the best solution, might be able to do something
very simlpe with the string or stringbuilder class...but if regex are the
way to go ,this should work:

string valueIWant = Regex.Replace(input, "(?<five>.{5})", "${five}<br>");

Karl
 

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

Forum statistics

Threads
474,431
Messages
2,571,679
Members
48,796
Latest member
Greg L.

Latest Threads

Top