LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-11-2013, 08:01 AM   #1
raggmopp
LQ Newbie
 
Registered: Jun 2003
Posts: 4

Rep: Reputation: 0
help with regex


Hi all

I'm trying to write a regex within a perl script to identify items created by Oracle SR module.

As files are received I am looking for directory names with the pattern of SR###### - this is the minimum. (That would be the alpha chars SR followed by 6 numerics.) Acceptable characters are alphanumerics, hyphen (-) and underscore (_) up to 25 total length.

The SR can be upper or lower case followed by 6 numerics. The remaining 17 characters cannot have any spaces.

Been looking and trying, here is my latest

Code:
/(^[Ss][Rr]\d{6})+([\w_-]$)/
As an example, a file arrives with the name of
Quote:
SR123456
- this would be accepted.
A file name of
Quote:
SR123456_acme
or
Quote:
sr123456-acme
would also be accepted.

A file name of
Quote:
123456_acme
is not accepted (does not begin with SR) nor is
Quote:
SR123456-this job
(space in the name)

Many thanks
 
Old 04-11-2013, 08:05 AM   #2
pan64
LQ Addict
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 21,850

Rep: Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309Reputation: 7309
move that +
/(^[Ss][Rr]\d{6})([\w_-]+$)/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] differences between shell regex and php regex and perl regex and javascript and mysql golden_boy615 Linux - General 2 04-19-2011 01:10 AM
Perl to find regex and print following 5 lines after regex casperdaghost Linux - Newbie 3 08-29-2010 08:08 PM
Regex Help subcon42 Linux - General 4 03-13-2010 02:57 AM
regex with sed to process file, need help on regex dwynter Linux - Newbie 5 08-31-2007 05:10 AM
Need a regex, I suck at regex's d3funct Programming 4 02-25-2002 08:28 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration