Home > Enterprise >  Python regex. Get the last word from a sequence
Python regex. Get the last word from a sequence

Time:11-03

I have a line like this: jsdata="l7Bhpb;_;CJWKh4 cECq7c;_;CJWKiA" data-ved="2ahUKEwjxq7L29Yr7AhWM7qQKHRABDVEQ2esEegQIGxAE">

I need to get the word CJWKiA. But I don't understand how to write it in the regex language.

My failed attempt: jsdata=\". ?;. ?\" This returns the entire string, including the word I need :(

I don't understand how to get only CJWKiA word, I need something pattern like this: jsdata=\"l7Bhpb;_;CJWKh4 cECq7c;_;(CJWKiA)\"

There may be different words, I only need to get the last one

CodePudding user response:

/jsdata="[^"]*;([^;"]*)"/gm

You can't have double quotes in the attribute.

  • Related