Announcement

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

  • ustrregexra("rivera, william c..", "..", ".") returns unexpected results

    I am cleaning a variable with the names of various individuals, and sometimes names contain two periods in a row when they should only contain one. The name "rivera, william c.." is an example of this. I want to clean this string to "rivera, william c." but the command
    Code:
    disp ustrregexra("rivera, william c..", "..", ".")
    returns "..........". Is there some escape sequence I am unaware of?

  • #2
    In a regular expression, the period matches any character, so you have to escape it with a backslash for it to be taken literally.
    Code:
    . disp ustrregexra("rivera, william c..", "\.\.", ".")
    rivera, william c.
    
    .

    Comment


    • #3
      Originally posted by William Lisowski View Post
      In a regular expression, the period matches any character, so you have to escape it with a backslash for it to be taken literally.
      Thanks for the help William.

      Comment


      • #4
        Code:
        disp ustrregexra("rivera, william c..", "[.]+", ".")
        https://www.regular-expressions.info/charclass.html
        https://unicode-org.github.io/icu/us...racter-classes

        Comment

        Working...
        X