This week's book giveaway is in the Spring forum.
We're giving away four copies of Spring in Action (5th edition) and have Craig Walls on-line!
See this thread for details.
Win a copy of Spring in Action (5th edition) this week in the Spring 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
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How to interpret this regex?  RSS feed

 
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello!

I have a regex :

Can someone explain to me what it means?

Thank you!
 
author
Posts: 23811
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Volodymyr Levytskyi wrote:
I have a regex :

Can someone explain to me what it means?



Interesting. I am not even sure if this is a valid regex, as I am not sure if the "-" character is allowed in the position that it is in. And if it is allowed, then I am still not sure if it is valid, as there may be an extra "]" remaining. Perhaps, someone better with regular expressions can shine a better light here.


In the meantime, can you tell us what you think that this regex is supposed to do?

Henry
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for reply!

I need to understand only this part
\p{Thai}

I found this regex here
 
Henry Wong
author
Posts: 23811
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Volodymyr Levytskyi wrote:Thanks for reply!

I need to understand only this part
\p{Thai}

I found this regex here




Oh, I see. The "-" character, in that position, is a subtraction operator. Interesting.

That site also answers your question -- it is a character in the character set of Thai characters.


And BTW, the current Java regex engine does not support the subtraction operator. It also does not support the Thai character set.... so, basically, that regex is invalid when using the current Java regex engine.

Henry
 
Bin Smith
Ranch Hand
Posts: 514
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you!

Java supports character class subtraction and intersection and union in regex. The syntax is different.
See official tutorial.
 
Henry Wong
author
Posts: 23811
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Volodymyr Levytskyi wrote:
Java supports character class subtraction and intersection and union in regex. The syntax is different.
See official tutorial.




Yeah, I know that -- that is why I explicitly stated "subtraction operator"...

Henry



PS... Interesting topic. Have a cow...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!