Help - Search - Members - Calendar
Full Version: help with regular expressions
Linuxhelp > Support > Programming in Linux
Hello , I am learning regular expressions. I have spent many hours searching for an answer. So I decided just to ask as I hope there could be a simple answer.


To my understanding that code snippet selects a seires of 4 o's if they are in the end of a string. The problem is I want it to select both upper and lowercase letters in an elegant way.

I could maybe have it a way it says "4x o or O " . But this would complicate everything and be alot of typing effort. Is there a way to have this oooo$ to find both lower and uppercase O's so oOoO would be found if it was at the end of a string?

Thank you , please help me
In what programming language?
python , but I'm not there yet. I understood regular expressions are the same in every language but used of course different languages have different implementations. Using just the plain python string tools would make things more complicated. If there is no way to keep this simple I think I will make everything lowercase so this should not be an issue.
RegExps are the same at a basic level in most languages - But the more advanced bits differ. As an example, PHP has two different regexp libraries, the default PHP one, and a perl-compatible version.

PHP has a seperate case-insensitive function for regexps - Not sure if the same is true for python though.

I think the following might do it

Yeah that is correct. If you are planning to use Python then it would be like this.
import re
p = re.compile(r"[oO]{4}")
for x in file:
   m =

All th best
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2018 Invision Power Services, Inc.