0

I'm using the following regex to clean up a document that has had apostrophes accidentally replaced with double quotes:

([a-zA-Z]\"[a-zA-Z])

That find's the first pattern match within the string, but not any subsequent ones. I've used the '*' operator after the group, which I understood would return multiple matches of that pattern, but this returns none. I've tested the regex here by adding double quotes to the example string.

Does anyone know what the operator I need is for this example?

Thanks

3
  • 1
    What is the code you are using? Commented Sep 19, 2015 at 15:26
  • 1
    @AnandSKumar i'm just testing the above regex at the link given for now. Commented Sep 19, 2015 at 15:27
  • 1
    if you want all matches you need findall , if you are using search you will just get the first Commented Sep 19, 2015 at 15:30

1 Answer 1

3

You might need to turn on global matching, which in Python is done by using re.findall() instead of re.search(). On Regexr, the global flag is enabled like this:

regex flags menu on top right corner http://puu.sh/kgLFC/5958420d09.png

Sign up to request clarification or add additional context in comments.

1 Comment

ah yes, thanks. i havent used regexes for about six months and i appear to have forgotten more than i thought.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.