Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
bencoder
on Dec 20, 2013
|
parent
|
context
|
favorite
| on:
Regex Golf
what's the pattern on "Abba"? I thought it was just to exclude doubled letters but I have doubles on two words on the left hand side as well (noisefully and effusive, in case the word lists are the same)
shdon
on Dec 20, 2013
|
next
[–]
Excluding doubled consonants that have the same vowel on both sides of the pair:
^((?!([aeiou])([^aeiou])\3\2).)*$
The following also works for the testcases and is shorter:
^((?!(.)(.)\3\2).)*$
surreal
on Dec 20, 2013
|
parent
|
next
[–]
Can get 2 more points with:
ef|^((?!(.)\2).)*$
But I reckon yours wins for having a pair of breasts in the middle
moron4hire
on Dec 20, 2013
|
prev
|
next
[–]
well, if you are
strictly
interested in matching with the fewest characters, regardless of the apparent pattern:
^(.)(.).*\2\1$
danielweber
on Dec 20, 2013
|
parent
|
next
[–]
Your anchors at the end make it match nothing.
moron4hire
on Dec 20, 2013
|
root
|
parent
|
next
[–]
sorry, misreplied. This was for palindromes.
abus
on Dec 20, 2013
|
prev
[–]
5. Abba (^unv|.u|z|ph|mi|st|vi|tan)
haha
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: