Java-Gaming.org    
Featured games (78)
games approved by the League of Dukes
Games in Showcase (429)
Games in Android Showcase (89)
games submitted by our members
Games in WIP (468)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  help with reg expression  (Read 605 times)
0 Members and 1 Guest are viewing this topic.
Offline Kommi

Junior Member




All opinions will be lined up and shot!


« Posted 2006-01-31 23:37:43 »

I am trying to write a reg expression with the following rules:
Must start with a lower case letter, can have any characters in between EXCEPT NUMBERS, must end with a lower case letter

the expression I came up with is the following:
1  
[a-z]+([^0-9]*?)[a-z]+


the problem is that "section9" will yeild "section", and "se-ction9" will yeild "se-ction". But "se1ction9" will break it down into 2 mathces, "se" and "ction". How can I change my expression so that "se1ction9" is rejected completely?

Kommi
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #1 - Posted 2006-01-31 23:47:02 »

I don't think you need the '?' in your example.

I always use this site http://www.regular-expressions.info/tutorial.html as a reference when I'm trying to grok regular expressions.

I think you just need to add beginning of line and end of line markers to what you have

1  
^[a-z]+([^0-9]*?)[a-z]+$


http://www.regular-expressions.info/anchors.html

see also http://www.regular-expressions.info/wordboundaries.html if you are matching this inside a longer string.

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

theagentd (6 views)
2014-04-24 23:00:44

xsi3rr4x (83 views)
2014-04-15 18:08:23

BurntPizza (75 views)
2014-04-15 03:46:01

UprightPath (86 views)
2014-04-14 17:39:50

UprightPath (69 views)
2014-04-14 17:35:47

Porlus (86 views)
2014-04-14 15:48:38

tom_mai78101 (109 views)
2014-04-10 04:04:31

BurntPizza (169 views)
2014-04-08 23:06:04

tom_mai78101 (265 views)
2014-04-05 13:34:39

trollwarrior1 (216 views)
2014-04-04 12:06:45
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!