View Single Post
  #2 (permalink)  
Old 07-25-2007, 12:42 AM
velhari velhari is offline
D-Web Programmer
 
Join Date: Mar 2007
Location: Chennai
Posts: 67
velhari is on a distinguished road
Send a message via AIM to velhari
Thumbs up Re: Can any one give regular expression for this string?

Quote:
Originally Posted by raj View Post
hi,

Can any one give solution for this using Regular Expression or any other php

functions?

I have the string:

$vStr = ' hi this "Raj Test" regular "expression functions" '

i want split this string using space but any string within the double quotes

you should take as single word.


i want to store an array like this:

$arrVal = ("hi", "this", "Raj Test", "regular", "expression functions")

Hi Raj,

For Your Query, I found that answer and i hope that its a Correct one.

Here the Code for your query about Splitting a string blahhh......

PHP Code:

$vStr 
' hi this "Raj Test" regular "expression functions" ';
$arrVal preg_split("/\s(\"[a-zA-Z]+\s[a-zA-Z]+\")*/",$vStr,-1,PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY);

print_r$arrVal); 
Regards,
VELHARI
Reply With Quote