• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

I am not able to dissect the regular expression

 
Ranch Hand
Posts: 163
1
jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have got a regular expression in my code which checks for special characters. But i could not able to dissect it how its working ?

^[^:>#*]+|([^:>#*][^>#*]+[^:>#*])$


Thanks in advance

swapna
 
Ranch Hand
Posts: 1704
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check the below tutorial, should help you to understand:
http://www.vogella.com/articles/JavaRegularExpressions/article.html
 
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The API documentation of the Pattern (<-click) class can help you with that.

 
lowercase baba
Posts: 13091
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Just like any programming task, try and break it down into smaller parts that you can understand. Also, tell us where exactly you get lost. Surely some parts of it make sense...
 
Marshal
Posts: 79704
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
There are far better tutorials available than that one. The Java Tutorials section, for example.
 
Swapna latha
Ranch Hand
Posts: 163
1
jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all. I will follow the tutorials and come back with the answers and doubts

thanks in advance

swapna
 
Campbell Ritchie
Marshal
Posts: 79704
381
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You’re welcome

That regex seems to have repeated elements. If you work out what the repeating element in square brackets means, you are a long way towards solving the whole problem.
 
Swapna latha
Ranch Hand
Posts: 163
1
jQuery Eclipse IDE
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have learned the basics of regular expression. Thanks to all. I got one problem with my regex.


My regex is written in such a way that it should not allow alpha numeric, and special characters. Thats fine, but its failing in one scenario for targetPage and that is Prestige$%$lll.jsp. How to make sure that it should work.
I am getting the following error:




thanks in advance

swapna
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Swapna latha wrote:My regex is written in such a way that it should not allow alpha numeric, and special characters. Thats fine, but its failing in one scenario for targetPage and that is Prestige$%$lll.jsp. How to make sure that it should work.


Fairly obviously, by making sure that it 'understands' the "%nn" syntax.

My suggestion: write a little program that does this using ONLY standard String methods, and then translate it to a regex. You may find that your program is actually faster than a regex; and for something complicated like this, it's highly likely to be more readable too.

Winston
 
Sometimes you feel like a nut. Sometimes you feel like a tiny ad.
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic