質問

I have the following code in a HTML page:

src="/images/picture1.gif"  ONMOUSEOVER="itempopup(event,'69168298'
src="/images/picture2.gif"  ONMOUSEOVER="itempopup(event,'69168223'
src="/images/picture3.gif"  ONMOUSEOVER="itempopup(event,'69168243'
src="/images/picture4.gif"  ONMOUSEOVER="itempopup(event,'69168249'
src="/images/pic1.gif"  ONMOUSEOVER="itempopup(event,'69168249'
src="/images/pictures10.gif"  ONMOUSEOVER="itempopup(event,'69168249'

and I want to build a Map with words of gifs that have picture+number -> {picture1=69168298, picture2=69168223 ...} I've tried to capture the word picture+number but I didn't found the right combination. Examples: ^(picture.)+$ , ^((picture).)+$, ^(?'picture'.)$. Thanks in advance!

役に立ちましたか?

解決

That is because your limiting the string using the ^$ characters. Just do it as follows:

(pic(ture)?s?\d+).*?event,'(\d+)'

And the \1 and \3 captured groups will contain the picture name and event id respectively

Demo

The regex above will also match cases in your example such as pic1 and pictures10, and even pics123

他のヒント

With something like this :

/(picture[0-9]+).*'([0-9]+)'/

you will capture "picture1" and "69168298"

/(pic.).gif.\'(\d+)/gi could work possibly.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top