Regex for repeated character?
How do I make a regular expression which will match the same character
repeated one or more times, instead of matching repetitions of any
(possibly non-same) characters like ".+" does? In other words, I want a
pattern like this:
>>> re.findall(".+", "foo") # not what I want
['foo']
>>> re.findall("something", "foo") # what I want
['f', 'oo']
.
Relevant Pages
- Re: RegEx: How to ignore the number of whitespaces?
... a "simpler" regular expression syntax is likely to bite you eventually, ... but that some of these character sequences may be "marked" as ... This is a regular expression "if" conditional statement, ... do not understand why the pattern "personal computer" will only match ... (microsoft.public.dotnet.framework) - Re: Emoticon text parser
... That is very close to a regular expression already. ... Most of these are character sets. ... We can ease the pain with the COMMENT flag of Pattern; ... The pattern really just addresses strings that are *exactly* 2-7 chars ... (comp.lang.java.programmer) - Re: Regex for repeated character?
... Leif K-Brooks wrote: ... > How do I make a regular expression which will match the same character ... > repeated one or more times, instead of matching repetitions of any ... (comp.lang.python) - Re: Identifying allowed characters using Regular Expression
... > that control I am using regular expression, ... > that particular pattern. ... > character will apear & user need not to enter any value for that. ... (microsoft.public.dotnet.languages.csharp) - Re: preg_replace: removing IMG-tags from string?
... The regular expression (or pattern) is quite simple: ... '>' - again, is straight text. ... character in the entire string. ... (alt.php) |
|