Regex: Does /w means [a-zA-Z] or [a-zA-Z0-9_] as most tutorials mention \w -Matches the word characters?
<p>I have just started with Regular Expressions and was to solving this <a href="https://www.hackerrank.com/challenges/valid-username-checker" rel="nofollow noreferrer">question</a> in which the task is to check whether that username is valid. A valid username will have the following properties:</p>

<ol>
<li>The username can contain alphanumeric characters and/or
underscores(_).</li>
<li><p>The username must start with an alphabetic character.</p></li>
<li><p>8&lt;=(Username Length)&lt;=30.</p></li>
</ol>

<p>I am using <a href="http://www.tutorialspoint.com/java/java_regular_expressions.htm" rel="nofollow noreferrer">this</a> 
as my reference that says </p>

<blockquote>
  <p>\w Matches the word characters.</p>
</blockquote>

<p>and I came up with a solution like this <code>String pattern = "^\\w(\\d|\\w|_){7,29}$";</code> which is not the correct solution.
And after searching for a while I found the correct solution is </p>

<p><code>String pattern = "^[a-zA-Z][a-zA-Z0-9_]{7,29}$";</code> which is pretty clear to understand.</p>

<p>What I want to confirm is <code>(\\w|\\d|_)</code> equivalent to <code>[a-zA-Z0-9_]</code> or not? </p>

<p>I think they are because <code>String pattern = "^[a-zA-z](\\w|\\d|_){7,29}$";</code> is accecpted for all test cases.</p>

<p>Also, this stackoverflow <a href="https://stackoverflow.com/questions/28226004/regex-difference-between-a-za-z-s-and-w-d">post</a> has two different equivalent expressions for <code>\\w</code> as answers with one upvote each, want to know which one is correct <code>[A-Za-z\s]</code> or <code>[A-Za-z0-9_]</code> ?</p>