Need help for Regex

  • Thread starter Thread starter Evgeny Zoldin
  • Start date Start date
E

Evgeny Zoldin

Hi All,

I want to capture the argument of some javascript function call in HTML
source code, namely HTML-Page contains

<script....>
func ( 'something1\'something2' );
</script...>

or

<script....>
func ( "something1\"something2" );
</script...>

I try to capture whole argument of the function call by the following:

string s = html_source;
Regex re = new Regex(@"(?<a>'.*?(?!<\)')"); // or new
Regex("(?<a>\".*?(?!<\\\\)\")");
Match m = re.Match(s);
Group g = m.Groups["a"];
string r = g.Value;

and here r is <'something1\'> but not <'something1\'something2'> as I want.
What's wrong?

Thanx
 
Evgeny Zoldin said:
Hi All,

I want to capture the argument of some javascript function call in HTML
source code, namely HTML-Page contains

<script....>
func ( 'something1\'something2' );
</script...>

or

<script....>
func ( "something1\"something2" );
</script...>

I try to capture whole argument of the function call by the following:

string s = html_source;
Regex re = new Regex(@"(?<a>'.*?(?!<\)')"); // or new
Regex("(?<a>\".*?(?!<\\\\)\")");
Match m = re.Match(s);
Group g = m.Groups["a"];
string r = g.Value;

and here r is <'something1\'> but not <'something1\'something2'> as I
want.
What's wrong?

Maybe that should be "...(?<!\\)..." instead of "...(?!<\\)..."?

Niki

PS: Please don't Multi-Post.
 
Back
Top