How to ignore whitespace in a regular expression subject string ?

How to ignore whitespace in a regular expression subject string ?

Asked on January 11, 2019 in Regex.
Add Comment


  • 2 Answer(s)

    To ignore whitespace in a regular expression subject string use this:

    Use optional whitespace characters \s* in between every other character in regex.

    /cats/ -> /c\s*a\s*t\s*s/
    
    
    Answered on January 11, 2019.
    Add Comment

    Try below points to ignore whitespace in a regular expression subject string:

    Use \s* inbetween every character in search string and for cat use c\s*a\s*t\s*s\s*s.

    Refer this link for working : http://www.rubular.com/r/zzWwvppSpE.

     

    Answered on January 11, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.