Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can use do this pattern:</p> <pre><code>/u/\w* </code></pre> <p>It will match the string <code>/u/</code> followed by zero or more letters, numbers, or underscores. To ensure that the string consists only of this pattern, use start (<code>^</code>) and end (<code>$</code>) anchors, like this:</p> <pre><code>^/u/\w*$ </code></pre> <p>For example:</p> <pre><code>string result = Regex.Match(input, @"^/u/\w*$").Value; </code></pre> <hr> <p>If you're trying to do some special parsing of HTML, I'm afraid regular expressions are a pretty bad option. You really should find some way of properly parsing the document first. Nevertheless, here's a <em>very</em> crude pattern that will ignore this sequence if it happens to be within inside an <code>href</code> attribute (it also assumes the attribute value will be surrounded by quotation marks):</p> <pre class="lang-none prettyprint-override"><code>(?&lt;!href="[^"]*)/u/\w* </code></pre> <p>For example: </p> <pre><code>string input = @"&lt;a href=""http://x/u/foo""&gt;/u/bar&lt;/a&gt;"; string pattern = @"(?&lt;!href=""[^""]+)/u/\w*"; string Regex.Match(input, pattern).Value; // will match /u/bar but not /u/foo </code></pre> <hr> <p>This pattern will match any sequence that doesn't have a word character (letter, number, or underscore), quote, or forward slash in front of it: </p> <pre class="lang-none prettyprint-override"><code>(?&lt;![\w""/])/u/\w* </code></pre> <p>This example shows how it can be used get all matches from the string:</p> <pre><code>var input = @"/u/username /u/username this is this/is/u/user &lt;a href=""http://www.regex.com/u/something/"" /&gt;"; var pattern = @"(?&lt;![\w""/])/u/\w*"; foreach(Match match in Regex.Matches(input, pattern)) { System.Console.WriteLine(match.Value); } </code></pre> <p>The output will me:</p> <pre><code>/u/username /u/username </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload