So I'm working on some php, and looking for some help with regular exp.
I have an array of string looking like this:
$variable_with_strings
array(
[0][art] => >AngusDelu -
[1][art] => >PatatasJr -
[2][art] => >AngusHabane *
[3][art] => >Papas Med *
[4][art] => >AngusDelu*
[5][art] => >Papas Med*
[6][art] => >AngusHabane**
[7][art] => >Papas Med**
[8][art] => >Papas Med_*-
[9][art] => >Manza Med_*-
)
I loop tru each one, treating as single variable ($variable_with_strings
And I want to split the string in two for later group it
something looking for a regex with preg_split()
like this:
(I need the two parts; 1.-the description item and 2.- the group signs)
for each one I expect to have:
$word = array
[art] => >AngusDelu
[sep] => -)
$word = array(
[art] => >PatatasJr
[sep] => -)
$word = array(
[art] => >AngusHabane
[sep] => *)
$word = array(
[art] => >Papas Med
[sep] => *)
$word = array(
[art] => >AngusDelu
[sep] => *)
$word = array(
[art] => >Papas Med
[sep] => *)
$word = array(
[art] => >AngusHabane
[sep] => **)
$word = array(
[art] => >Papas Med
[sep] => **)
$word = array(
[art] => >Papas Med
[sep] => _*-)
$word = array(
[art] => >Manza Med
[sep] => _*-)
)
So I was using something like:
$word = preg_split('/[^\w]/',$variable_with_strings);
But this splits every white space,
This is kinda tricky, I guess, because in the first character there is a >
always, and the last characters are *
, _
, -
or some time a space before these " ", and some times the special chars come in 1, 2 or even 3 at the end.
can this be done this way?
thanks