LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-16-2009, 11:19 AM   #1
HarryBoy
Member
 
Registered: Apr 2008
Distribution: MontaVista Linux Version 4.0.1, Professional Edition
Posts: 215

Rep: Reputation: 16
RegExp help


I have a regular expression that compares a string. It is as follows:
var string = new RegExp( ' [ ' + leters + ' ][ ' + letters + ' 0-9]+ ' );

This is used to check if a string starts with a letter and then letters or numbers.

how do I modify this so it can start with letters OR numbers, instead of just letters?

Thanks
 
Old 02-16-2009, 11:31 AM   #2
theYinYeti
Senior Member
 
Registered: Jul 2004
Location: France
Distribution: Arch Linux
Posts: 1,897

Rep: Reputation: 61
First, I suppose it is Javascript language.
Next, I find very strange the way you write this regex, and with way too many spaces; programming leaves little room for approximation…
Your example would have been simpler as “new Regex('[A-Z][A-Z0-9]+','i')” and then it would still have been false, missing the extra “^” at the start of the regex to match only at the start of the string.

As for the answer, something like this should do: “new Regex('^[A-Z0-9]{2,}','i')”.

Yves.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Help with regexp anupamsr Linux - Software 4 03-05-2008 07:43 AM
regexp ovince Programming 8 06-17-2007 11:54 AM
regexp stomach Linux - Software 7 02-15-2006 07:33 PM
little help for regexp EmOuBi Linux - Newbie 6 08-06-2005 03:19 AM
regexp help ... pld Programming 1 03-15-2005 04:45 PM


All times are GMT -5. The time now is 04:01 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration