• Home
  • Recent Q&A
  • Java
  • Cloud
  • JavaScript
  • Python
  • SQL
  • PHP
  • HTML
  • C++
  • Data Science
  • DBMS
  • Devops
  • Hadoop
  • Machine Learning
in JAVA by
Q:
What is the use of \w in regex?

a) Used for a whitespace character

b) Used for a non-whitespace character

c) Used for a word character

d) Used for a non-word character

1 Answer

0 votes
by

(c) Used for a word character

Reason: In java, the "\w" regex is used to match with a word character consists of [a-zA-Z_0-9]. For example, \w+ matches one or more word character that is same as ([a-zA-Z_0-9] +).

The regex \W, \s, and \S are used for a non-word character, a whitespace character, and a non-whitespace character, respectively. Hence, the \w regex is used for a word character.

Related questions

0 votes
asked Apr 9 in JAVA by Robindeniel
0 votes
asked Apr 9 in JAVA by Robindeniel
...