1

I have an address as string and i want to show it in 2 lines , for example address

 A Building 10 mynew Road Singapore 208718

I want to show as follows ,

A Building 10 mynew Road
Singapore 208718

I have done it in a following way ,

Dim parts1 As String() = Regex.Split(addr, "singapore", RegexOptions.IgnoreCase)
 If (parts.Length > 1) Then
    addr = parts(0) + "<br/> Singapore" + parts(1)
 End If

But the problem i have is , the text Singapore may come as S'pore as well , in this time how I can split with regular expression ?

0

1 Answer 1

2

Converting my comment to answer so that solution is easy to find for future visitors.

You may use this regex with an alternation:

"[Ss](?:inga|')pore"

RegEx Details:

  • [Ss] matches letter s or S
  • (?:inga|'): matches text inga or '
  • pore: Matches text pore
Sign up to request clarification or add additional context in comments.

2 Comments

I'm just curious to know what does ?:inga means , is it a global search ?
(?:...) is a non-capture group. See details

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.