Linux Help
guides forums blogs
Home Desktops Distributions ISO Images Logos Newbies Reviews Software Support & Resources Linuxhelp Wiki

Welcome Guest ( Log In | Register )



Advanced DNS Management
New ZoneEdit. New Managment.

FREE DNS Is Back

Sign Up Now
 
Reply to this topicStart new topic
> help with regular expressions, upper and lowercase letters
jantteri
post Dec 5 2005, 12:42 AM
Post #1


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 5-December 05
Member No.: 5,819



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.

oooo$

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
Go to the top of the page
 
+Quote Post
Corey
post Dec 5 2005, 12:48 AM
Post #2


Its GNU/Linuxhelp.net
*******

Group: Admin
Posts: 1,254
Joined: 21-September 02
From: St John's, Newfoundland, Canada
Member No.: 3



In what programming language?


--------------------
Corey Quilliam
(former) Linuxhelp.ca Administrator
cquilliam-AT-gmail-dot-com

Want to help out Linuxhelp.net? Check out our Linuxhelp Wiki and see if there are some articles you would like to submit!!

--
Ubuntu 8.04 64-bit - Work Laptop (HP-Compaq NC6400 Core2)
Kubuntu 8.04 64-bit - Desktop (HP m8120n QuadCore)
Ubuntu 6.04 - Server (I'm not upgrading this baby until support runs out in 2012) (Some old POS dell)
Go to the top of the page
 
+Quote Post
jantteri
post Dec 5 2005, 01:32 AM
Post #3


Whats this Lie-nix Thing?
*

Group: Members
Posts: 2
Joined: 5-December 05
Member No.: 5,819



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.
Go to the top of the page
 
+Quote Post
DS2K3
post Dec 5 2005, 12:01 PM
Post #4


Its GNU/Linuxhelp.net
*******

Group: Support Specialist
Posts: 1,284
Joined: 14-November 04
From: Southampton, Hampshire
Member No.: 4,165



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
CODE
[Oo]{4}


D


--------------------
Fixed your problem? Let us know!
richard@linuxhelp.net

www.Gathr.co.uk Online Event Management
Go to the top of the page
 
+Quote Post
Hemant
post Dec 7 2005, 02:51 PM
Post #5


RMS is my Hero
******

Group: Support Specialist
Posts: 782
Joined: 6-October 02
From: Trichy,INDIA
Member No.: 29



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


All th best


--------------------
Hemant Kumar
user posted image
hemant@linuxhelp.net
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 22nd October 2017 - 07:53 PM