Evening all,
I'm looking at passing text from a monitoring system as a variable and then using the regex/LUA to look for duplicate usernames
Example line of text is:
Unathorised Change Profile Entries: (Audit trail entry) USERNAME - USERNAME
Any advice would be greatly appreciated.
Big thank you for the help above.
Here's my final working code:
a = alarm.get ()
str = a
if (string.match(a.message, "(%a+) %- %1$")) then
print("Matching!")
else
print("No match")
end
Related
Completely new to regex only read a few guides my problem is as follows. A 3rd party solution is being connected to our Adfs 2016 enviroment. We have run into a problem as the solution cannot handle long usernames and the Upn and email of our users are in the format of users initials 3 or 4 letters.department#ourcompany.com, so Dave Dibley Jr would be ddj.department#ourcompany.com
what i would like to do is use Regex to Cut everything after the initals from the claim any suggestions how to do this ?
You can use RegEx for string manipulation in the Claims Rules Language. Fx:
c:[type == “http://contoso.com/role”]
=> issue (Type = “http://contoso.com/role”, Value = RegExReplace(c.Value, “(?i)director”, “Manager“);
Pass through any role claims. If any of the claims contain the word “Director”, RegExReplace() will change it to “Manager”. For example, “Director of Finance” would pass through as “Manager of Finance”.
See https://social.technet.microsoft.com/wiki/contents/articles/16161.ad-fs-2-0-using-regex-in-the-claims-rule-language.aspx for more information.
I am struggling with writing a regex for validating email address for only one domain.
I have this expression
[A-Z0-9a-z._%+-]+#[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}
But the issue is that for example hello#gmail.com.net is valid and I only want to be only valid for only one domain. So hence I do not want hello#gmail.com.net to be valid.
Help is needed. Thank you!
try this [A-Z0-9a-z._%+-]+#[A-Za-z0-9-]+\.[A-Za-z]{2,64}.
In your regex is a dot in the allowed characters behind the #.
You can use something like:
\b[A-Z0-9a-z._%+-]+#gmail\.com\.net\b
Regex Demo
I found this regex for Swift:
[A-Z0-9a-z._%+-]+#[A-Za-z0-9.-]+\\.[A-Za-z]{2,64}
It has an extra backslash.
I found it here: http://emailregex.com/
Regards,
Melle
I know you already accept an answer but this idea just cross my mind. You can use URLComponents to split the email address into user and host and validate each component separately:
func validate(emailAddress: String) -> Bool {
guard let components = URLComponents(string: "mailto://" + emailAddress),
let host = components.host else
{
return false
}
return host.components(separatedBy: ".").count == 2
}
print(validate(emailAddress: "hello#gmail.com")) // true
print(validate(emailAddress: "hello#gmail.com.net")) // false
print(validate(emailAddress: "hello")) // false
Your requirement has a big flaw in it though: valid domains can have two dots, like someone#bbc.co.uk. Getting a regex pattern to validate an email is hard. Gmail, for example, will direct all emails sent to jsmith+abc#gmail.com to the same inbox as jsmith#gmail.com. The best way is to perform some rudimentary check on the email address, then email the user and ask them to click a link to confirm the email.
You can try with below pattern.
/^(([^<>()\[\]\.,;:\s#\"]+(\.[^<>()\[\]\.,;:\s#\"]+)*)|(\".+\"))#((REPLACE_THIS_WITH_EMAIL_DOMAIN+\.)+[^<>()[\]\.,;:\s#\"]{2,})$/i;
for Eg.
/^(([^<>()\[\]\.,;:\s#\"]+(\.[^<>()\[\]\.,;:\s#\"]+)*)|(\".+\"))#((gmail+\.)+[^<>()[\]\.,;:\s#\"]{2,})$/i;
I have many urls from the same newspaper, each url has a depository for each writer.
For example:
http://alhayat.com/Opinion/Zinab-Ghasab.aspx
http://alhayat.com/Opinion/Abeer-AlFozan.aspx
http://www.alhayat.com/Opinion/Suzan-Mash-hadi.aspx
http://www.alhayat.com/Opinion/Thuraya-Al-Shahri.aspx
http://www.alhayat.com/Opinion/Badria-Al-Besher.aspx
Could someone help me please with writing a regular expression something that would generate all writers urls?
Thanks!
In order to get Zinab-Ghasab.aspx, you need no regex.
Just iterate through all of these URLs and use
print s[s.rfind("/")+1:]
See sample demo.
A regex would look like
print re.findall(r"/([^/]+)\.aspx", input)
It will get all your values from input without .aspx extension.
You can use findall() method in "re" module.
Assuming that you are reading the content from a file
import re
fp = open("file_name", "r")
contents = fp.read()
writer_urls = re.findall("https?://.+.com/.+/(.*).aspx", contents)
fp.close()
Now, writer_urls list is holding all the required urls.
If you can help me I will be very grateful.
My problem is i send a request via google chrome like that :
http://localhost:8080/Webservise/rest/getinfo?user=user1&pwd=rdd#en&sscc=009
and whene i test the url he return :
user = user1
pwd=rdd
sscc= null
Because the # is an special caracter
any proposition ?
Thanks a lot.
Yes # is a fragment identifier. To ensure its interpreted as part of a query string you must URL encode it (to %23) - You should be doing this as routine for all query string values.
I have absolutely no idea about regex at all. I am trying to perform email validation in a PHP signup script (to check if a valid email has been entered). I have got a script from the internet but I don't know how it works and I am completely unfamiliar with the functions used. I found out that the function they used (eregi_replace()) is deprecated in favor of preg_replace(). Firstly, can someone guide me through the steps of the function below, and secondly can you explain the preg_replace() function and how it works?
The validation script:
$regex = "([a-z0-9_.-]+)". # name
"#". # at
"([a-z0-9.-]+){2,255}". # domain & possibly subdomains
".". # period
"([a-z]+){2,10}"; # domain extension
$eregi = eregi_replace($regex, '', $email);
$valid_email = empty($eregi) ? true : false;
The script was sourced from here
regex are not needed here:
filter_var('bob#example.com', FILTER_VALIDATE_EMAIL);
if you want training i suggest you to visit http://www.regular-expressions.info and http://php.net
To quickly test a pattern you can use this online tool: http://regex.larsolavtorvik.com/