Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #83 Regex with character repetition

Declare regular expression r matching the strings "http", "htttp", "httttp", etc.

import static java.util.regex.Pattern.compile;
import java.util.regex.Pattern;
Pattern r = compile("ht{2,}p");
import java.util.regex.Pattern;
Pattern r = Pattern.compile("htt+p");
(def r #"htt+p")
 auto r = regex("htt+p");
using System.Text.RegularExpressions;
var r = new Regex("htt+p");
import std.regex;
auto r = regex("htt+p");
r = Regex.compile!("htt+p")
import "regexp"
r := regexp.MustCompile("htt+p")
import Text.Regexp.Posix
r :: String -> Bool
r = (=~ "htt+p")
const r = /htt+p/
r = "htt+p"
preg_match_all("/htt+p/", $r, $matches)
uses RegExpr;
with TRegExpr.Create('htt+p') do try
finally
  free;
end;
my $r = qr/htt+p/;
import re
r = re.compile(r"htt+p")
r = /htt+p/
extern crate regex;
use regex::Regex;
let r = Regex::new(r"htt+p").unwrap();

New implementation...
< >
deleplace