1
<script language='javascript' src='http://api.psusedo.com/board@top_<?=$id?>'></script>

I try to save the value of script src through regular expression in two.

One tries to save before the _ sign(Ex:http://api.psusedo.com/board@top_ ) and the other one after the _ sign.(Ex: )

\_(.*)

The string after _ including this regular expression was found.

How do I save a character string around _ and how do I do it?

In2DaC
  • 11
  • 2
  • 1
    What happened to the previous question you asked on this topic? Please don't duplicate questions on the same topic. – chris85 Mar 13 '17 at 03:32

1 Answers1

0

You can try this:

src\s*=\s*'([^_]*)_([^']*)'\s*>
  1. in group 1 you get the value before underscore (_) sign
  2. in group 2 you get the value after underscore (_) sign

Demo

Sample Code:

$re = '/src\s*=\s*\'([^_]*)_([^\']*)\'\s*>/';
$str = '<script language=\'javascript\' src=\'http://api.psusedo.com/board@top_<?=$id?>\'></script>';
preg_match_all($re, $str, $matches, PREG_SET_ORDER, 0);
// Print the entire match result

var_dump($matches);

Mustofa Rizwan
  • 10,215
  • 2
  • 28
  • 43