Extract number + letter combination from string - regex

I'm intrested in extracting c8127c6ea6a44c109b5e35ce61cd4b0096a9c6dc from a string that looks like this:
?t=c8127c6ea6a44c109b5e35ce61cd4b0096a9c6dc'
Here is my attempt at capturing the result in to a group.
?t=([a-e]\d+)'
Could anyone point me in the right direction, since this obviously isn't working?
http://regexr.com?383s6

You wanna put the \d in the [a-e] block and escape the ?:
\?t=([a-f\d]+)'
(and I assume you're looking for hexadecimal so it should be a-f?)

You can use this regex:
\?t=([a-e0-9]+)'
OR usig negation:
\?t=([^']+)'

In Ruby language you can try Rubular tool online to test your regular expressions.
\?t=(\w+)'
should do the match.

Related

Oracle regex string not beginning with '40821'

I am trying to define a regex that matches string with numbers and it's not begining with 40821, so '40822433598347597' matches and '408211' not. So, I've tried
^(?!40821)\d+
Works perfectly in my regex editor, but still doesnt work in oracle. I know, it's very easy to use where not but my goal is to do it using only regex. Please, some pieces of advice, what am I doing somthing wrong?
According to this question, negative lookahead and lookbehind are not supported in Oracle.
One way would be to explicitly enumerate the possibilities using alternation. In your case it would be something like:
^([012356789]|4[123456789]|40[012345679]|408[013456789]|4082[023456789])
I think you try to use negative lookbehind:
(?<!a)b matches a "b" that is not preceded by an "a"
Source: http://www.regular-expressions.info/lookaround.html
That kind of Perl's sytax is not supported by Oracle.

Regex Extract in Google Docs for capturing the end of variable strings

In Google Docs, if I have a series of strings like "Something.Here.Search.Term.Chicago", where the last component after "Term." can be anything.
How do I use regex extract to only capture what comes after "Term."?
Note that the length of the string varies before Term so I can't use Left or Right and position since it's always different.
You can use a positive look-behind as well, to avoid having to capture with groups:
/(?<=Term\.).*/
Though depending on the language you are implementing this with, it may not support look-behinds (namely JavaScript).
If you don't want to mess about with capturing groups and you know the component you want is the substring between the last . and the end of the string, you could use
[^.]+$
Here's what worked for me using you sample data:
=REGEXREPLACE(A1; ".*Term.(.*)" ; "$1")
I don't know Google Docs, but normally in regular expressions, you would do
"Something\.Here\.Search\.Term\.(.*)"
The () means capture and remember the pattern within. In this case .* means everything. You can usually access the pattern as $1, etc. in Javascript.
See Examples of Regular Expressions
What about using a "look-ahead" expression (?=),
then something repeated followed by a word boundary?
Something like this:
(?=Term\\.).*\W

Regex for just only numbers

I haven't used regular expressions soo much, so I'm having difficulty . I want regex that only validates that the field contains digits, but that does not care about how many.
It should approve 77 and 2377? But do not approve 77.43 or xyz777.
How can I get this using regular expression? Is this expression ^[0-9]+$ ok or not
It's OK. You can just use ^\d+$ for all it matters anyway.
Yes, this regex is perfectly valid and does what you think it does, although if your regex engine supports this you could use \d, whichs stands for [0-9].
A simpler regex would be to invert your match and check for non-digit numbers: \D.

Check extension with RegEx

For example I've got string /wiki/File:test.JPG I should check if it has one of extention "jpeg","jpg","png","gif"
Currently I've written that link.search(/.[j,p,g][p,i,n][e,g,f][g]?/gi) and it is works, but I'd like better regular expression.
Just write the regex as a list:
/\.(jpe?g|png|gif)$/gi
(note the escaped dot (.))
EDIT: Added a $.
Just for future reference this tool is invaluable when dealing with regex in flash:
Web Version:
http://gskinner.com/RegExr/
Desktop Version:
http://gskinner.com/RegExr/desktop/
Maybe something like this?
/\.(jpe?g|jpg|png|gif)$/gi
The dot must be escaped (with a slash) and I wrote $ to point to the fact it needs to be the end of the string.
var pattern: RegExp = /\.(jpe?g|png|gif)$/gim
If you also want case-insensitive matching try this:
\.(?i)(jpe?g|png|gif)$
The dot must be escaped, else it'd match any character :)

is it the right reqular expression

i have following regular expression but it's not working properly it takes only three values after # sign but i want it to be any number length
"/^[a-zA-Z0-9_\.\-]+\#([a-zA-Z0-9\-]+\.)+[a-zA-Z0-9]{2,4}$/"
this#thi This is validated
this#this It is not validating this expression
Can you please tell me what's the problem with the expression...
Thanks
If you want your regex to match "any number length" then why are you using {2,4}?
I think a better example of the strings you're trying to match might give others a better idea of what you want, because based on your regex it is a bit confusing what you're looking for.
Try this:
^[a-zA-Z0-9_.-]+#([a-zA-Z0-9-]+\.)+[a-zA-Z0-9]{2,4}$
The main problem is that you didn't escape the dot: \.. In regular expression the dot matches everything (mostly), making your regex quite liberal.