How to allow multiple spaces in between the text using regex?

Member

by adan , in category: Third Party Scripts , a month ago

How to allow multiple spaces in between the text using regex?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by muriel.schmidt , a month ago

@adan 

To allow multiple spaces in between text using regex, you can use the following regular expression pattern:

1
s+


This pattern matches one or more whitespace characters (spaces, tabs, newlines, etc.) in between text.


For example, if you want to match a string that contains multiple spaces between words, you can use the following regular expression:

1
[A-Za-z]+s+[A-Za-z]+


This pattern will match two words separated by one or more spaces. If you want to allow any number of spaces between words, you can modify the pattern to:

1
[A-Za-z]+s*[A-Za-z]+


This pattern will match two words separated by zero or more spaces.