Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to get particular text using regex

import re
cookie_jar = "<RequestsCookieJar[<Cookie JSESSIONID=EA47DC319D1977863BBEC8E4AFB408DF.node60877 for tah.appiancloud.com/suite>, <Cookie SCS_REMEMBER_ME_COOKIE=jA0EAwMC3Bc7KwH4uMsB0kUBOqr2TjQT9LIqoOmfUaCFiPtA7JqG9A8lihrCrKyg6yK2EYEqkHvCfEQwVTcKP9CYYFtwGkG7rGDH8UY6IPhJPKa2tsg for tah.appiancloud.com/suite>, <Cookie SPRING_SECURITY_REMEMBER_ME_COOKIE=TExNTXNyJTJGQjBqVTN6OWFZQ0xSV1RuOVhVcEhtczdhNlFXd0swJTJCd2VGOEElM0Q6TGRQU0MlMkZHRVgyYVhKZldBTVQwQWdQVTMzWTA5VENvaUY0NWxBdlhiYSUyRlklM0Q for tah.appiancloud.com/suite>, <Cookie __appianCsrfToken=d815e694-2118-4b3e-92c7-6b750b9557d2 for tah.appiancloud.com/suite>, <Cookie __appianMultipartCsrfToken=f80ce677-9adf-409e-a755-89105f51437e for tah.appiancloud.com/suite>]>
"
print(re.findall("__appianCsrfToken\s*=\s*([^\;]+);?",cookie_jar))

Required output: d815e694-2118-4b3e-92c7-6b750b9557d2

Is there any solution to get __appianCsrfToken only the value

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

regex description https://regex101.com/r/b42RMQ/1

import re
cookie_jar = "<RequestsCookieJar[<Cookie JSESSIONID=EA47DC319D1977863BBEC8E4AFB408DF.node60877 for tah.appiancloud.com/suite>, <Cookie SCS_REMEMBER_ME_COOKIE=jA0EAwMC3Bc7KwH4uMsB0kUBOqr2TjQT9LIqoOmfUaCFiPtA7JqG9A8lihrCrKyg6yK2EYEqkHvCfEQwVTcKP9CYYFtwGkG7rGDH8UY6IPhJPKa2tsg for tah.appiancloud.com/suite>, <Cookie SPRING_SECURITY_REMEMBER_ME_COOKIE=TExNTXNyJTJGQjBqVTN6OWFZQ0xSV1RuOVhVcEhtczdhNlFXd0swJTJCd2VGOEElM0Q6TGRQU0MlMkZHRVgyYVhKZldBTVQwQWdQVTMzWTA5VENvaUY0NWxBdlhiYSUyRlklM0Q for tah.appiancloud.com/suite>, <Cookie __appianCsrfToken=d815e694-2118-4b3e-92c7-6b750b9557d2 for tah.appiancloud.com/suite>, <Cookie __appianMultipartCsrfToken=f80ce677-9adf-409e-a755-89105f51437e for tah.appiancloud.com/suite>]>"
print(re.findall(r"__appianCsrfToken\s*=([^\s]+)",cookie_jar)) #['d815e694-2118-4b3e-92c7-6b750b9557d2']
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading