I am trying to extract some information from outlook email messages and write the output to a text file. I a doing it in a macro by getting the emails in a specific folder and then parse each message for specific strings. Sample input string below
[optional strings here]
Name: John Doe
[optional strings here]
Email: u#me.com
[optional strings here]
Tel: 555-555-5555
I tried using a regex to extract the information however I am not able to come up with the proper regex that will extract what I need and ignore the rest
Here is what I have so far:
(^.*\b(Name|E-mail|Primary-Phone)\b.*$)
With some offline help I got the regex that does what I need:
\n?Name:\t*?([^\t]*?)\t*?\r.*?E-mail:\t*?([^\t]*?)\t*?\r.*?phone:\t*?(\d{3}-\d{3}-\d{4}).*?
Thanks
Timur
Related
I've got such a column named X and I need to get the phase after word "name"
Here is an example of one row of json type:
{"id":"5df8c913e069a09e0467179e","name":"Contacts in description","vote":"REFUSE","notice":{"text":"Contacts or URLs in description are not allowed on JamesEdition","severity":"PROBLEM"},"wordHighlighting":[{"words":[{"word":"yes","regex":"/^yes$/"}],"variableName":"$text.hasUrl"}]}
So the result I need in this case is: Contacts in description
Also sometimes there are several name in one string: I need to grab them all
Thanks a lot for attention!
Try JSON_EXTRACT:
SELECT JSON_EXTRACT('{"id":"5df8c913e069a09e0467179e","name":"Contacts in description","vote":"REFUSE","notice":{"text":"Contacts or URLs in description are not allowed on JamesEdition","severity":"PROBLEM"},"wordHighlighting":[{"words":[{"word":"yes","regex":"/^yes$/"}],"variableName":"$text.hasUrl"}]}', '$.name')
I am using Azure Search and I want to search for this specific word with the dash in between:
Top-Light
My json post body is:
{
"search":"/(.*)top-light(.*)/",
"queryType":"full",
"top":1000
}
The result is empty because he replaces the "-" with empty "". so he is trying to search for toplight which does not exist.
I tried the escape character:
"search":"/(.)top-light(.)/"
and I received an error:
The request is invalid. Details: parameters : Invalid JSON. An unrecognized escape sequence '\-' was found in a JSON string value.
I tried to use:
\-
(-)
(-*)
(.*)
\\-
/-
and none of them works. Any suggestion?
thank you!
Just filter it as a string. [search.ismatch('"top-light"', '[whatever the field is]').
I am trying to understand a mysql injection not working as expected.
I have a php script that does a login based on username and password supplied on a webpage. The query string looks like this:
$querystr = "SELECT COUNT(*) FROM usertbl WHERE user='$user' and pass='$pass'";
Username and password are escaped before they are used in the querystr above. This means any apastroph(single quote) is escaped as well.
I found a blog describing this very issue here: mysql_escape_string-the-charset-vulnerability.
I tried to replicate what´s explained on that blog, but when I supply hexadecimal characters for user or pass on the website, php somehow doesn´t interpret them as hex it seems.
When I enter for the username on the webpage(password empty):
user\xbf\x27
the query logged by MySQL is:
SELECT COUNT(*) FROM usertbl WHERE user='user\xbf\x27 or 1=1--' and pass=''
So, to me it looks like the hexadecimal characters are not interpreted as such.
For some more debugging, I created the following php script, which I ran on the server:
<?php
header('Content-type: text/plain; charset=gbk');
$hex="\xbf\x27";
echo mysql_escape_string($hex);
?>
The output is:
�\'
Does anybody have an idea why it might not work for me?
Thank you
When you type $hex="\xbf\x27"; in a php script, PHP parses it and stores the string formed by the hexadecimal bytes BF 27.
When you type \xbf\x27 in a web page, it is sent verbatim to the server, so the query ends up with the literal text «\xbf\x27».
The way to exploit it would be to enter that character in the browser (eg. changing your browser encoding to iso-8859-1 and pasting a ¿), or sending a fake HTTP request where you directly insert in the wire any byte you wish. If you are performing the injection through HTTP GET, there's an easy way to insert which is using %-escapes, ie. "&user=user%bf%27%20or%201=1--&pass=".
I am trying to create a regex which identifies an email between a long string.
The below regex works fine for email :
^[A-Z0-9._%-]+#[A-Z0-9.-]+\.[A-Z]{2,4}$
But I need to create a regex such that this should return true :
SELECT 'hfdjj abc#enmail.com jkdfk' REGEXP '^[A-Z0-9._%-]+#[A-Z0-9.-]+\.[A-Z]{2,4}$';
I want to have any number of characters before and after the email.
Thanks,
Aman
If you're happy with the matching of the email, simply removing the ^ and $ characters from the start and end should suffice.
^ matches the beginning of the string.
$ matches the end of the string.
Between them, they are what's telling MySQL to not match where there are things either side of the email address.
I am trying to retrieve some information from a website using regular expression. I ended up with an output containing html entity for a special character.
For example, instead of Côté I am getting Côté.
Please help in retrieving the actual string. TIA.
HtmlDecode should work for you:
http://msdn.microsoft.com/en-us/library/7c5fyk1k.aspx
s = HttpUtility.HtmlDecode(s)