1

I have an array which is a product of preg_match_all, this array has elements from the HTML page which I get as a response to my curl request.

So in my array there is several elements like so:

<script>...</script> 

The one I need to select is in a form:

<script>write_which('X','Y','Good','N','Bad','P','Pending','R','Referred','I','Incomplete','D', 'Still in 3D-Secure redirect', 'L','Later','U','Unknown')</script>

first element in brackets, the "X", can have value of any of these letters: Y,N,P,R,I,D,L,U.

So my question is how to exactly match the element in array? As I tried many different regular expressions and can't figure it out.

Thank you for all help.

Jakub Zak
  • 1,212
  • 6
  • 32
  • 53

2 Answers2

1

Can you try this regex:

"#<script>\s*write_which\s*\(\s*'X'\s*,\s*'[YNPRIDLU]'.+?</script>#is"
anubhava
  • 761,203
  • 64
  • 569
  • 643
0

Do you only need to get the first element and has it always the same structure? If yes, try this out

.*?'(.*?)'

NewToObjectiveC
  • 83
  • 1
  • 2
  • 8