Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 02-16-2009, 10:19 AM   #1
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?

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

Rep: Reputation: 63
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')”.



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 06:43 AM
regexp ovince Programming 8 06-17-2007 10:54 AM
regexp stomach Linux - Software 7 02-15-2006 06:33 PM
little help for regexp EmOuBi Linux - Newbie 6 08-06-2005 02:19 AM
regexp help ... pld Programming 1 03-15-2005 03:45 PM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:50 AM.

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