Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Replacing a specific space with text (string)

    Hello,

    Hope you all are well.

    I am trying to replace a particular space within a text with a html line break code of <br> however, I am unable to figure out how to do so.

    Example:

    Code:
    set obs 5
    generate text = ""
    replace text = "1. A is less than B 2. B is less than C 3. C is greater than both A and B" in 1
    So I want to write a code such that it replaces space between last character and each number digit with <br>

    Code:
    1. A is less than B<br>2. B is less than C<br>3. C is greater than both A and B
    I hope I was clear in explaining. Please feel free to reply if there is still a confusion

  • #2
    Code:
    replace text =  ustrregexra(text, "([ ]+(?=[0-9]))", "<br>")

    Comment


    • #3
      This was nice, thank you!

      Comment

      Working...
      X