Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pattern Matching

Status
Not open for further replies.

BryanY

MIS
Aug 18, 2001
54
US
I was wondering what symbol/syntax to use that would represent any type of whitespace.

Basically i need to split each of the words in a string into seperate array elements. The only issue is that the words are seperated by an undefined amount of spaces or tabs.

@data = split (/ /, $_); # what should i use for the pattern match?
 
Whitespace is the \s symbol. That will match spaces and tabs. If you want a true whitespace handler then add on the other "white" items like line feeds:

[\s\n]
or
[\s\0x0A\0x0D] (In case you want to handle both UNIX and DOS files)

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top