Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You've specified "all" for the ValueSpec, which means you'll get all matching subgroups. In this case that includes "1.". Instead of "all" you can just specify "first" and all you'll get is the first matching group (the complete IP).</p> <p>You should do it like this:</p> <pre><code>Url = "http://192.168.1.241/mod/fun?arg", re:run(Url, "(\\d{1,3}\\.){3}\\d{1,3}", [{capture, first, list}]). </code></pre> <p>This will return:</p> <pre><code>{match,["192.168.1.241"]} </code></pre> <p>More info <a href="http://www.erlang.org/doc/man/re.html#run-3" rel="nofollow">here</a>.</p> <p><strong>EDIT:</strong> Just in case you miss it, here's the relevant part in the docs (which explain it a lot better than me :-)):</p> <blockquote> <p>Specifies which captured (sub)patterns are to be returned. The ValueSpec can either be an atom describing a predefined set of return values, or a list containing either the indexes or the names of specific subpatterns to return.</p> <p>The predefined sets of subpatterns are:</p> <p><strong>all</strong></p> <p>All captured subpatterns including the complete matching string. This is the default.</p> <p><strong>first</strong></p> <p>Only the first captured subpattern, which is always the complete matching part of the subject. All explicitly captured subpatterns are discarded.</p> <p><strong>all_but_first</strong></p> <p>All but the first matching subpattern, i.e. all explicitly captured subpatterns, but not the complete matching part of the subject string. This is useful if the regular expression as a whole matches a large part of the subject, but the part you're interested in is in an explicitly captured subpattern. If the return type is list or binary, not returning subpatterns you're not interested in is a good way to optimize.</p> <p><strong>none</strong></p> <p>Do not return matching subpatterns at all, yielding the single atom match as the return value of the function when matching successfully instead of the {match, list()} return. Specifying an empty list gives the same behavior.</p> </blockquote>
    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.
    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