• Post Reply Bookmark Topic Watch Topic
  • New Topic

Regex expression  RSS feed

 
Subhadeep biswas
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.</DispatcherRequest>
2.</SendRequest>


i need a REGEX for it to match the above two


i am trying <\\/*Request>..but it is not working

String.matches() returns false..

please help me...
 
Bill Clar
Ranch Hand
Posts: 163
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're on the right track.

What does your asterisk represent? What expression does it match?

 
Philip Thamaravelil
Ranch Hand
Posts: 99
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
try..


<\/\w+Request>




Cheers,
Philip
 
Rob Spoor
Sheriff
Posts: 21135
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's still wrong. There is a need for + or *, but not both. Neither should be applied to /. And the / does not need to be escaped since it means nothing in regexes.
 
Subhadeep biswas
Greenhorn
Posts: 14
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
please tell me the pattern which matches the above two expression and matches() returns me "true"..
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Subhadeep biswas wrote:please tell me the pattern which matches the above two expression and matches() returns me "true"..



The requirement here is for those two XML closing tags -- why would you want a pattern that can match some other tag? ..... The pattern should be "</(Dispatcher|Send)Request>".

Henry
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I should also point out that using something that you don't understand is *not* a good idea. I would highly recommend that you don't use any regex that you don't know (or unsure of) how it works.

Henry
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!