I need to correlate the CSRF_NONCE value from the response body of a gatling script.
PTC.flex.csrf.setNonceData('CSRF_NONCE', 'YSgUCGWgJBu8/Fm7I1k7MQuZR1PImDzVGWxSOxeYVUmIvRPuG2Nwfx/RR3WPnnLZDmx6cSvJYSaGzWyMVx8gPFKXEC2PxWONLER+SkrXT3OFkxvKKnhdcQPsU27bwWQ=');
I tried using the below regex check
.check(regex("""PTC.flex.csrf.setNonceData('CSRF_NONCE', '(\S[a-z]*[0-9]*[A-Z]*)');""").saveAs("CSRF1"))
but always getting the output as
"regex(PTC.flex.csrf.setNonceData('CSRF_NONCE', '(\S[a-z]*[0-9]*[A-Z]*)');).find.exists, found nothing"
Please suggest the correct way to give the expression.
Your regex is wrong.
Try
"""PTC\.flex\.csrf\.setNonceData\('CSRF_NONCE', '([a-z0-9A-Z=/\+]*)'\);"""
You can use https://regexr.com/ or write "your regex".r.findAllMatchIn("your string") in Scala to test your regex.
Related
I have the following: "/assets/blt49012d3c84501502/CA_the_first_avenger.jpg"... "/assets/blt6d6c300f37d5df8c/husky_puppies.jpg" inside a huge string text (json data stringified)
I am not sure how to write a regex for it, I've tried doing: /\/assets\/blt[a-zA-Z0-9]+/g but it only returns the first part : /assets/blt49012d3c84501502
thanks!
I think this is the regex you are looking for:
/(\/assets\/\w*?\/\w*?\.jpg)/g
You can test it out here
This should do the trick --
\/assets\/blt[a-zA-Z0-9]+\/[\D|_]+\.jpg
https://regex101.com/r/aP4gI0/1
I am trying to make a regex that checks if the url a user is posting, are valid.
I have created the following regex:
/https?\:\/steamcommunity\/.com\/profiles|id\/[a-zA-Z0-9]/
But that isn't working. Is there a regex master, here that can tell me what i am doing wrong?
The links i am trying to validate are looking like:
https://steamcommunity.com/profiles/76561198009610232/
https://steamcommunity.com/id/rasmusvejby/
ANSWERE
/(?:https?:\/\/)?steamcommunity\.com\/(?:profiles|id)\/[a-zA-Z0-9]+/
Try this regex:
(?:https?:\/\/)?steamcommunity\.com\/(?:profiles|id)\/[a-zA-Z0-9]+
See this demo:
Regex Demo
The "g" modifier is just so you can see it test it in different strings, but you probably dont need it.
The accepted answer to this question will also match this url for example:
https://steamcommunity.com/profile/thisisimpossible
I am using the following regex to prevent non numeric characters when the id is prepended by profile/ rather than id/. Not necessarily prettier but it does the job.
^(?:https?:\/\/)?steamcommunity\.com\/(?:profiles\/[0-9]{17}|id\/[a-zA-Z0-9].*)$
I'm trying to get a parameter stored in a html comment using regex. However when I execute the expression it return the widest string possible and not all the possible matches.
So I have some content that might include this string:
<!--url:/new--><!--title:My Title-->
I use the following simply expression to get the url I need:
/<!--url:(.*)-->/
The issue I have is that the result match part of the title which is of course valid but not what I was looking for
["<!--url:/new--><!--title:My Title-->", "/new--><!--title:My Title"]
There is workarounds I can use like making sure there is a line break after each parameter line but I prefer to have a solid regex and also of course understand what I missing out.
PS: Please comment if you come up with a better title.
Make the regex non-greedy:
/<!--url:(.*?)-->/
You can test this regex by clicking here:
Regex101
I have a string like #'test'
and I have to get only test word without #' '
how can I match them with regular expression at javascript?
try the regex below:
#\'([^']*)\'
get group(1)
and if your language supports look-behind,( e.g. python, perl, java...):
(?<=#\')[^']*
should work too without grouping.
oh, just saw you edit your question, as far as I know, js doesn't support look-behind, then you could take the option 1.
var firsName= "#'test'"
var objName = firsName .replace('#', "'");
lastName=objName.replace(/[']/g,'');
I fixed it like that. I dont know is it best way or not. thanks for helping
I'm using the following for email validation:
var filter = /^([\w]+)(.[\w]+)*#([\w]+)(.[\w]{2,3}){1,2}$/; // For Email Validation
if (filter.test(emailInputVal))) {console.log('good')}
For some reason the above does not work with emails that have a subdomain Any ideas why?
xxxx#xxx.xxx.com
Thanks
Because your regular expression is incorrect. Try this instead:
var filter = /^\w+(?:\.\w+)*#\w+(?:\.\w+)+$/;
This link may help you lots when validating email addresses:
http://www.regular-expressions.info/email.html
Official RFC 2822 standard
This non-trivial simplified regular expression conforming to RFC 2822 standard:
var filter = /[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*#(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+(?:[A-Z]{2}|com|org|net|edu|gov|mil|biz|info|mobi|name|aero|asia|jobs|museum)\b/;
That is one weird regex. It's certainly not doing what you're expecting it to do, for example because the dot isn't escaped when you do mean a literal dot.
Since it's impossible to really validate an email address with a regex anyway - why not go for something simpler?
/^[A-Z0-9._%+-]+#[A-Z0-9.-]+\.[A-Z]{2,6}$/i
This will still match some invalid addresses and will reject some valid addresses (as all readable regexes do), but in the end you have to send a confirmation mail to a user-submitted mail address and see if you get a reply if you truly want to validate it.
You can't reliably validate email addresses with regular expressions. What I'd do:
use a simple expression like /^[^#]+#([A-Za-z0-9-]+\.)*[A-Za-z0-9-]+$/ for client-side validation to catch typos
check the DNS record on the server-side
send a confirmation mail
Your last component is: any length word, then one or two instances of (dot, two-or-three-letter word). I would expect "xxxx#xxx.xxx.com" to work, but perhaps not more realistic examples like "xxxx#xxx.example.com" because your domain name is not a two-or-three-letter word.
Do yourself a favor: use simply /^[^# ]+#[^# ]+\.[^# ]+$/ More about this: http://nedbatchelder.com/blog/200908/humane_email_validation.html
I am not sure if the above code will work any format, because there is an extra ) in the if condition, removing it works for the sub domain too:
if (filter.test(emailInputVal)) {console.log('good')}