0

I am doing the Pig Latin text conversion:

One of the requirements is putting qu together.

What I did re.findall(r'^qu', token)

but it only accepts qu together if the word/token starts with qu

If the word/token starts with aqu then it does not recognize qu together.

What I want is to recognize qu no matter the placement, including if it starts with Qu.

How do I fix this?

YatShan
  • 425
  • 2
  • 8
  • 22
floss
  • 2,603
  • 2
  • 20
  • 37
  • 2
    Remove the caret. And instead of just `qu` maybe: `[Qq]u`. Is regex necessary though? – JvdV Feb 17 '20 at 21:31

1 Answers1

2

Remove the ^ from it, that cause this. The caret mean basically "start the matching from the beginning of the line (token in your case)".

Eraklon
  • 4,206
  • 2
  • 13
  • 29
  • 3
    This should work. Just to contribute a little bit, when I have to work with regular expressions I always use https://regexr.com/ to check if I'm doing something right. You can find some similar sites on google. – Thales Marques Feb 17 '20 at 21:34