Jump to content
Sign in to follow this  
Underdogger

RegExp Problem

Recommended Posts

Underdogger

<META NAME="class" CONTENT="我是人(哈哈)(呵呵)">

<META NAME="class" CONTENT="我是人(你好)">

<META NAME="class" CONTENT="我是人">

Maybe there are three modes in the HTML file..

(Sometimes appears line 1, sometimes appears line2, sometimes appears line3)

But how do I use one pattern to get 我是人 PS.(maybe other words, just grab the value from this position)

Thanks a lot.

Edited by Underdogger

Share this post


Link to post
Share on other sites
AZJIO

#include <Array.au3>

$sText= _
'<META NAME="class" CONTENT="???(??)(??)">' & @CRLF & _
' <META NAME="class" CONTENT="???(??)">' & @CRLF & _
' <META NAME="class" CONTENT="???">'

$aRes=StringRegExp($sText, '(<META NAME="class" CONTENT="\?\?\?(?:\(\?\?\))*?">)', 3)

_ArrayDisplay($aRes, 'Array')

Share this post


Link to post
Share on other sites
sentry07

I think you're missing a character set or something, Azjio. :) His example text doesn't have ?s in it. I believe it's Mandarin. I'm not proficient enough in RegEx to know unicode capturing. Would Mandarin characters still be picked up by the w quantifier?

Share this post


Link to post
Share on other sites
Underdogger

I think you're missing a character set or something, Azjio. :) His example text doesn't have ?s in it. I believe it's Mandarin. I'm not proficient enough in RegEx to know unicode capturing. Would Mandarin characters still be picked up by the w quantifier?

I do not know why this pattern [u4E00-u9fa5] cannot get the Chinese characters in AutoIt...?

It would run normally in C#...

Edited by Underdogger

Share this post


Link to post
Share on other sites
czardas

I do not know why this pattern [u4E00-u9fa5] cannot get the Chinese characters in AutoIt...?

It would run normally in C#...

Try this instead:

Local $sString = ChrW(0x6211) & ChrW(0x662F) & ChrW(0x4EBA) ; Test string
If StringRegExp($sString, "[\x{4E00}-\x{9FA5}]") Then MsgBox(0, "Chinese", "Found")
Edited by czardas

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×