Jerykso
Jerykso

Reputation: 31

Python regex. Get the last word from a sequence

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

Upvotes: 1

Views: 49

Answers (1)

Alichu
Alichu

Reputation: 26

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

You can't have double quotes in the attribute.

Upvotes: 1

Related Questions