i have this string ++++++1DESIGNRESULTSM25Fe415(Main)
and i have similar string about 2000 lines from which i want to split these..
[++++++] [1] [DESIGNRESULTS] [M25] [Fe415] [(Main)]
from the pattern only the 2nd 4h and 5th value changes
eg.. ++++++2DESIGNRESULTSM30Fe418(Main) etc..
what i actually want is:
- Split the first value [++++++]
- Split the value after 4 Character of [DESIGNRESULTS] so ill get this [M25]
- Split the value before 4 Character of [(Main)] so ill get this [Fe415]
- After all this done store the final chunk of piece in an array.
the similar output what i want is
Array ( [0] => 1 [1] => M25 [2] => Fe415 )
Please help me with this…
Thanks in advance 🙂
Your data split needs are a bit unclear. A regular expression that will get separate matches on each of the chunks you first specify:
If you only need the two you are asking for at the end, you can use
You could also replace
\d\dwith\d+if the number of digits is unknown.However, based on your examples it looks like each string chunk is a consistent length. It would be even faster to use