List Info

Thread: Strip whitespace from start and end of String




Strip whitespace from start and end of String
country flaguser name
United States
2007-08-27 19:12:18
Hi

I need help trying to use regular expression to validate
that there is
no white space at the start and end of a string. Also the
string can
contain spaces, just not at the start and end. Also the
string can be
a single character. Any help will be much appreciated.

I got this far but it does not cater for a single character

namePattern = "((^[A-Z0-9]([A-Z_0-9
]+)?[A-Z0-9]$){1,12})";

Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


Re: Strip whitespace from start and end of String
country flaguser name
United States
2007-08-27 22:14:47
^[^ ](.*[^ ])?$

On Aug 27, 6:12 pm, doodler <achick...gmail.com> wrote:
> Hi
>
> I need help trying to use regular expression to
validate that there is
> no white space at the start and end of a string. Also
the string can
> contain spaces, just not at the start and end. Also the
string can be
> a single character. Any help will be much appreciated.
>
> I got this far but it does not cater for a single
character
>
> namePattern = "((^[A-Z0-9]([A-Z_0-9
]+)?[A-Z0-9]$){1,12})";
>
> Thanks


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the
Google Groups "Regex" group.
To post to this group, send email to regexgooglegroups.com
To unsubscribe from this group, send email to
regex-unsubscribegooglegroups.com
For more options, visit this group at http://groups.go
ogle.com/group/regex
-~----------~----~----~----~------~----~------~--~---


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )