Home > Software engineering >  how to find out a specific text from a long text in python
how to find out a specific text from a long text in python

Time:12-26

I have a long text. how to get only "Brandshubs" from below HTML?

output = Brandshubs3.7

CodePudding user response:

You can use either text.find("Brandshubs") or utilize the Python re library if you need something more sophisticated.

CodePudding user response:

Just use re.search('Brandshubs', s) or findall function in python re library. But you will get the string Brandshubs always, that's not meaningful so I guess you want to check exists or count the times? For that you can check/count the results of these functions' return directly

  • Related