Jump to content

Delete Whitespace


gum1982

Recommended Posts

 

Can someone please help me.

 

Ive done this regular expression which works out as any code that starts with two letters and ends with four numbers.

 

i.e as1233

 

Im not very good with regular expressions all i want is it to allow spaces because the company has hand out the code to every as two letters SPACE and ends with four numbers.

 

ie as 1233

 

Here my regular expression


("^[[a-zA-Z]{2}[0-9]{4}]$") 

 

 

 

i see that \s strips whitespace but dont now how to implement this.

 

Any help Please?

Link to comment
https://forums.phpfreaks.com/topic/189762-delete-whitespace/
Share on other sites

\s doesn't strip white space. \s matches any whitespace character, eg a space, newline, tab etc.

 

To match a space add \s before [0-9] eg

("^[[a-zA-Z]{2}\s[0-9]{4}]$")

Alternatively you could just add a space instead

("^[[a-zA-Z]{2} [0-9]{4}]$")

Link to comment
https://forums.phpfreaks.com/topic/189762-delete-whitespace/#findComment-1001434
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.