Python - How to use regex to find a text?
Question: Please bear with me, I'm new in Python. I have a text, and I want to get the
value after `^s` until the next `^` so for example there's `^s100^` then the
value is `100`. This is what I've tried so far:

    
    
    #!/usr/bin/python
    
    import re
    
    text="^request^ #13#10#13#10^s100^GET http://facebook.com #13#10Host: http://facebook.com #13#10X-Online-Host: http://facebook.com #13#10X-Forward-Host: http://facebook.com #13#10Connection: Keep-Alive#13#10#13#10"
    if re.split(r'\^s',text):
        print "found it"
    

The problem is that it always returns `found it` even if I change the regex to
`re.split(r'\^bla',text)` and basically any text, it will always return `found
it` Please help me to fix it.


Answer: What you probably want is
[`re.search`](https://docs.python.org/2/howto/regex.html):

    
    
    import re
    
    text="^request^ #13#10#13#10^s100^GET http://facebook.com #13#10Host: http://facebook.com #13#10X-Online-Host: http://facebook.com #13#10X-Forward-Host: http://facebook.com #13#10Connection: Keep-Alive#13#10#13#10"
    m = re.search(r'\^s(.*)\^',text)
    print m.group(1)  # 100
    

