This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 2 years ago.
I'm trying to match e-mails with a string like:
s.te.e.ve.s.mit.h.p#gmail.com
Effectively I'm after any repeating pattern (of at least 4 times) of a string of characters followed by a period, with the last before the email domain not having a period.
I'm not great with Regex, but so far I've only come up with:
[aA-zZ\.]{4,}[aA-zZ]#.*
This matches what I need, however it also pulls more than I'd like.
Any advice?
Thanks for the help, I see now where I was making the mistake. Wiktor's answer seemed to work the best, though for some reason it would time out in Redshift if I didn't put . in brackets. [.]
The expression which appears to work correctly is:
^([a-zA-Z][.]){4,}[a-zA-Z]#.*
Related
This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 3 years ago.
Unfortunately I found that the existing examples are confusing and not similar enough to what I am trying to achieve. I need a regular expression to find occurencies of strings like
=> Test[a]
where between the special character > and Test there is exactly one space. The word Test can be replaced by any alphabetic string (=> Apple[b] is another example). I have worked out a regex for all except the first part with the block =>.
Can anyone help me?
I managed to find this expression
.(=>) [a-zA-Z]+\[a\]\.
and it works! Thanks everyone.
Try use this regex:
=> \S+
Here Is Demo
This question already has answers here:
How do I match any character across multiple lines in a regular expression?
(26 answers)
Regex search with pattern containing (?:.|\s)*? takes increasingly long time
(1 answer)
Closed 3 years ago.
A few times I saw regex experts say that using (.|\n)*? is a really, really bad idea.
Well, I do understand that it's better to replace it with the .* and use the /s flag. But sometimes the flags are not available, for example, when using regex within a text editor or other software with limited regex functionality. Thus, using something like (.|\n)*? might be the only option for multi-line matching.
So, what are the reasons to always avoid (.|\n)*??
This question already has answers here:
What is the best regular expression to check if a string is a valid URL?
(62 answers)
Closed 5 years ago.
Here is my regex that tries to match a valid URL:
^(https?:\/\/((\b\w[^-][a-zA-Z0-9-]{1,33})\.){1,34}([[a-zA-Z0-9]{1,6})\/?)$
and I've tried to find way to make a simple solution to forbid the use of a hyphen '-' in the beginning and end of a group of letters and numbers.
I'd tried to use \b\w[^-]. But it hasn't helped.
For example, my regex matches this string, but it shouldn't
http://example-.com
I found an answer by myself
^(https?:\/\/([WWW\.]|[www\.])?((([a-zA-Z0-9]|[a-zA-Z0-9][-][a-zA-Z0-9]){1,10})\.){1,33}([[a-zA-Z0-9]{1,6})\/?)$
its just a simple OR [a-zA-Z0-9]|[a-zA-Z0-9][-][a-zA-Z0-9]
If you'll find better solution pls send it :)
This question already has answers here:
Regex to match repeated characters
(3 answers)
Closed 6 years ago.
I am having a hard time with Go's regex. It seems it's different than other language, can someone help me on this.
Obj. I want MustCompile to find all repeated characters in the string.
APPLE (where P's repeating)
re := regexp.MustCompile("(\\w)\\${1}\\+")
Above is what I have tried but didn't work at all. Basically I wanted to do:
([A-Za-z])\1+
Can someone tell me what I am doing wrong?
Example below:
https://play.golang.org/p/DeuaIva968
Apparently Golang doesn't supposed back referencing due to efficiency. :(
Thank you everyone for your help.
This question already has answers here:
My regex is matching too much. How do I make it stop? [duplicate]
(5 answers)
Regular expression to stop at first match
(9 answers)
Closed 3 years ago.
I know this question has been asked many times, but when I attempted to use the accepted answer that I found here, it does not work, so I assume I'm missing something.
I was attempting to match the Mrs. in the string Rothschild, Mrs. Martin (Elizabeth L. Barrett) using this regular express:
.*, (.*\.).*
But this does not work because of the L.. I then attempted to add the ? a number of different ways, but it still matches all the way to L.. Some things I tried:
.*, (.*\.?).*
.*, (.*\.*?).*
.*, (.*\.+?).*
.*, (.*\.??).*
But none of these work. Can anyone see what I am missing here?
Regex Fiddle
Put ? after the * which was present inside the capturing group. .* is greedy and eats up characters as many as possible. You need to add a quantifier ? after the * to do a shortest possible match.
.*, (.*?\.).*
DEMO