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

Member

by adan , in category: Third Party Scripts , 4 months ago

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

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by muriel.schmidt , 4 months 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.

Related Threads:

How to replace spaces between words using regex?
How to match 10 numbers with or without spaces with regex?
How to allow only 1 forward slash in regex expression?
How to add the option to allow only one space in a regex?
How to allow execution of php in html file using .htaccess?
How to normalize text with regex?