This week's book giveaways are in the Cloud and AI/ML forums.
We're giving away four copies each of Cloud Native Patterns and Natural Language Processing and have the authors on-line!
See this thread and this one for details.
Win a copy of Cloud Native PatternsE this week in the Cloud forum
or Natural Language Processing in the AI/ML forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Knute Snortum
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Piet Souris
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Ganesh Patekar

Java REGEX Algorithm

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please explain about the algorithm of regex parser in Java or share any links to that.
 
Ranch Hand
Posts: 90
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Regex API is used for pattern matching against pattern specified by the user by regular expressions.

For instance, you need to avoid entering special characters by the end user for any field like First Name or Last Name, then you may make use of java.util.regex API.

Refer here for its API.

For example:
Pattern pattern = Pattern.compile("!@#$%"); // String which you want to restrict
Matcher matcher = pattern.matcher("stringToBeMatched"); // String that needs to be matched (may be entered by user for First Name)

matcher.find(); // returns true if string matched else false is returned

Perform action as per the output is returned.

Thanks,
Ashwini Kashyap | www.infocepts.com
 
Marshal
Posts: 65005
246
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to unpack the JVM code to try and work out the algorithm used. Try googling; there are probably sites which show the algorithm.
 
lowercase baba
Posts: 12753
51
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just wondering why you want to dig into this. One of the points of using a high-level language is that you don't need to know the details - it makes life SO much easier.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!