title: regex: \w EXCEPT underscore (add to class and then exclude from class)
body: <p>This question applies to Python 3 regular expressions. I think it might apply to other languages as well.</p>
  
  <p>The question could easily be misunderstood so I'll be careful in describing it.</p>
  
  <p>As background, <code>\w</code> means "a word character." In certain circumstances Python 3 will treat this as just <code>[a-zA-Z0-9_]</code> but if the regular expression is a string, it will be Unicode-aware so that <code>\w</code> means "any Unicode word character." This is generally a good thing as people use different languages, and it would be hard to construct a range like <code>[a-zA-Z0-9_]</code> for all languages at once. I think <code>\w</code> is therefore most useful in a multilingual setting.</p>
  
  <p>But there is a problem: What if you don't want to match underscores because you don't think they're really a word character (for your particular application)?</p>
  
  <p>If you're only focused on English applications, the best solution is probably to skip <code>\w</code> entirely and just use <code>[a-zA-Z0-9]</code>. But if you're focused on global applications and you don't want underscores, it seems like you might be in a really unfortunate situation. I haven't done it, but I assume it would be really tough to write a range that represents 100 languages at once just so you can avoid that underscore.</p>
  
  <p>So my question is: Is there any way to use <code>\w</code> to match any Unicode word character, but somehow also exclude underscores (or some other undesirable character) from the class? I don't think I've seen anything like this described, but it would be highly useful. Something like <code>[\w^_]</code>. Of course that won't actually work, but what I mean is "use a character class that starts with everything represented by <code>\w</code>, but then go ahead and remove underscores from that class."</p>
  
  <p>Thoughts?</p>