regexkitlite match? - iphone

i would like to get everything inbetween &v= and "> using a regex expression,
NSString *YouTubeRegex = #"/amp;v=([^(\">)]+)/";
But that regex is not returning any matches ? i know the coding is correct just not the regex expression any help ?
Thanks

Try this :
/amp;v=(.+?)">/
http://www.rubular.com/r/Lqb63CsN2p

Assuming the regex engine is Perl-like:
"/&v=(.*)>/"
should do the trick.

Related

Regrex query in DB2-LUW

I need a regrex query to match any string having given character. So i tried for example
SELECT wt.CHGUSER FROM "CDB"."WTBALL" wt where REGEXP_LIKE (wt.CHGUSER, '^\d*115*$');
So i am expecting to fetch all the strings having 115 somewhere in between each string. I tried many combinations but i am getting empty column or weird combination.
Are you sure You need a regex? You write "all the strings having 115 somewhere in between each string", but test for a all-digit string with "115" somewhere...
Btw. this could be done also without regex:
WHERE LOCATE('115', wt.CHGUSER) > 0
AND TRANSLATE(wt.CHGUSER, '', '0123456789') --if You really want to test all-digit string
why not use the native "LIKE" expression?
where wt.CHGUSER like '%115%'
This will give different results than your regexp because your expression is looking for '115' so long as there is a digit immediate before and after it. A more generic regexp, which matches your question, would be '.*115.*'
What about -
REGEXP_LIKE (wt.CHGUSER, '^*\d115\d*$');

Regex for email firstname.lastname

I'm looking to find email address that only match the pattern firstName.LastName#xxx.yyy in Scala / Spark
My issue is that "." is used in Scale regex for "Matches any single character except newline"
I tried with \\. but doesn't match as well
Here is my code:
val emailTest = "ja.mes#downstairs.com"
if (emailTest.matches("[A-Za-z]+\\.[A-Za-z]+#[A-Za-z0-9.-]"))
println("ok")
else
println("nok")
Thanks for your help
Matthieu
The . is fine, but you are only looking for one character after the #. Add a + to fix this:
"[A-Za-z]+\\.[A-Za-z]+#[A-Za-z0-9.-]+"

Preg_match one word followed with double quotes

I searched all the web but did not solve my problem.
I need a regular expression to match or replace a word folowed with a double quote.
Example :
uniquehereuniqueyouunique"can"uniquegetuniquefoounique"bar"
I need to replace all unique" by something (ex notunique). I tried :
preg_replace("/unique\"/", 'notunique', $contents);
but that don't match.
thanks for your help
I found it !
preg_replace('/unique."/', 'notunique', $contents);

Trouble determining the pattern for NSRegularExpression...?

i am relatively new to NSRegularExpression and just can't come up with a pattern to find a string within a string....
here is the string...
##$294#001#[12345-678[123-456-7#15665#2
I want to extract the string..
#001#[12345-678[123-456-7#
for more info I know that there will be 3 digits(like 001) between two # 's and 20 characters between the last two # 's..
I have tried n number of combinations but nothing seem to work. any help is appreciated.
How about something like this:
#[0-9]{3}#.{20}#
If you know that the 20 characters will always consist of digits, [ and -, your pattern would become:
#[0-9]{3}#[0-9\[\-]{20}#
Be careful with the backslashes: When you use create the pattern with a string literal (#"..."), you need to add an extra backslash before each backslash.
You can test NSRegularExpression patterns without recompiling each time by using RegexTester https://github.com/liyanage/regextester

Regex to retrieve string

I wish to match
&v=
and before
">
is there a regex match i could use
Example:
<a accesskey="1" href="/watch?gl=GB&client=mv-google&hl=en-GB&v=ubNF9QNEQLA">Test Your Awareness : Whodunnit?</a>
i only need the ubNF9QNEQLA
Thanks
/&v=([^(">)]+)/
/&v=(.*?)">/
The question mark tells the wild char matching to be lazy so it will stop at the first "> rather than at the last one.
/&v=(.*)>/
This solved it