如何写这个特殊的正则表达式

What is the regex I need to use if I

Need to select the "10" in player list and not the "10" from group

{"group":"10","player":["12","15","13","10","1"]}

Sorry I should have given a little more on the programming scope

The json string is supposed to be treated as a string and not json parsed because I need to use query in mysql to select rows that match this criteria..

for example, in the above example...

Select * from team Where jsondata=(Something to the effect that "10" can be found in player list but will ignore if "10" is found only in group)

If i use:

Select * from team Where jsondata LIKE'%"10"%'

then obviously it would be wrong because if the data was {"group":"10","player":[]} it would still qualify

i want to run a php command like preg_match to match the "10" form the player list if found

Thanks for those who have replied so far

I know you asked for a regular expression. However, if the string will always be a Python dict, then how about:

str = "{\"group\":\"10\",\"player\":[\"12\",\"15\",\"13\",\"10\",\"1\"]}"

"10" in eval( str )["player"]

This would test whether the string "10" exists for the list in the "player" key. You might want something slightly different. The point being, if the data will always be a serialized Python data structure, you'll be able to work with this data much more naturally as a Python data structure.

Note, since I was typing the string manually I had to escape the ". If you were reading this string from a file you wouldn't have to do that.

Try somenthing like this: "player":\[.*"(10)" or "player":\[("\d+",)*?"(10)"

Depends on, how strictly you like it.

In MySQL you can use this:

SELECT * FROM team WHERE jsondata REGEXP '"player":.*"10"'