Regular Expression

  • Thread starter Thread starter Guest
  • Start date Start date
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.
 
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

Back
Top