-5

I am trying to make regex for this string :

This is some string <select> this is another string <select var1> another string which can contain special characters <select var2> another variable string <select var1,var2>

I need to select all the strings not in select tag.

Select all string not within <select> tag

Can anyone help ? using PHP preg_match

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
Riyo
  • 33
  • 5
  • 2
    you should know how to [ask a good question](https://stackoverflow.com/help/how-to-ask) – Mohammad May 12 '17 at 13:28
  • What have you tried? What errors you're getting? – capcj May 12 '17 at 13:32
  • @Mohammad: Yes, I posted this question after 3 hours of searching. – Riyo May 12 '17 at 14:12
  • @Carlos : I tried (.*)/(.*) , it works fine on single instance of select tag but on multiple instance it is not returning anything. Thanks for helping out. – Riyo May 12 '17 at 14:13

1 Answers1

0

by using preg_split:

$str = 'This is some string <select> this is another string <select var1> another string which can contain special characters <select var2> another variable string <select var1,var2>';

$arr = preg_split('/\<.*?\>/',$str);
print_r($arr);
Mohammad
  • 3,449
  • 6
  • 48
  • 75