I am trying to import some Oracle SQL data into my MySQL database. At the moment I am using Notepad++ and the regular expression search feature to try and delete the timestamp information stored in each row. I have tried, unsuccessfully, to find the regular expression that would isolate the timestamp portion of this line and was wondering if someone could help.
values (4,21,22,221164,165375,0,0,21,144,0,0,605,to_timestamp('07-JAN-14 10.49.42.000000000 PM','DD-MON-RR HH.MI.SSXFF AM'),to_timestamp('07-JAN-14 10.49.42.000000000 PM','DD-MON-RR HH.MI.SSXFF AM'),'PROG',null);
If you want to remove the to_timestamp(...) you can use the following regex
to_timestamp\(.*?\)
Here you have the working example:
http://regex101.com/r/zK6lC5/1
Related
I am trying to build a regex in Excel;s data validation. However, it is not working.
Would you please explain how could I put data validation in Excel
I want last name data validation with characters, quote('), space and dot.
=ISNUMBER(MATCH("^[a-zA-Z\s,.']*$",F:F,0))
I am using above formula and, again, it is not working
For SSN, I am using following formula and it is not working
=AND(ISNUMBER(MATCH("/^\d{3}-\d{2}-\d{4}$/",A2,0)),LEFT(A2,1)>=0)
Please help me to build data validation from data tab or VBA script for the data validation.
The MATCH function in Excel is not used for regex matching.
But you do not need it here, it looks like.
To allow only letters and ,.' you could use formula like this:
=ISNUMBER(SUMPRODUCT(SEARCH(MID(A1,ROW(INDIRECT("1:"&LEN(A1))),1)," ,.'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")))
To validate an SSN try the formula from the guide here
=AND(LEFT(F1,1)>="0",LEN(F1)<10,ISNUMBER(F1))
Some more pointers:
More Data Validation examples
Adding validation to a cell using VBA is described here and using Regex in VBA here, as noted.
Unfortunately, the Match Function is not able to support regex. It can only match a single, constant value.
I suggest you take a look at This very detailed post, which explains beautifully how to use Regular Expressions in Excel.
Other than that, your Regular Expression looks to be in working order - if you get this set up, it should work immediately. Good luck!
I'm working on migrating a database into a sql project, and need to replace all instances of cross-database calls with a SQLCMD variable, and am struggling to write a regex to help me find the places I still need to update.
In the SQL, we have the following:
MyOtherDatabase.MySchema.MyTable
[MyOtherDatabase].MySchema.MyTable
Which I need to change to:
[$(MyOtherDatabase)].MySchema.MyTable
So far, I've come up with the following regex:
([^(]M|^M)yOtherDatabase
Which finds all places where "MyOtherDatabase" is used, and hasn't been replaced with the variable.
HOWEVER, it's also picking it up in SQL comments, such as:
-- I don't want to find MyOtherDatabase in this line
and
FROM ADifferentPlace -- Used to be MyOtherDatabase
If this was only a few instances, I'd live with it, but I've currently got 560 matches, most of which are one or the other of the above, making it very easy for human error to get in the way.
I'm using this regex in the "Search" box within Visual Studio 2015, with the "use regex" checkbox ticked.
any advice would be helpful!
Edit
Also need to NOT find the following:
from MyTable -- from MyOtherDatabase.MySchema.MyTable
If your environment supports variable-length negative lookbehinds, you could use the following to avoid matching any commented section :
search for (?<!--.*)MyOtherDatabase(?=]?\.)
replace by $(MyOtherDatabase)
If it doesn't, you can still match lines from the start :
search for ^((?:[^-]|-[^-])*)MyOtherDatabase(]?\.)
replace by \1$(MyOtherDatabase)\2
I'm using the following expression to filter Oracle Java vulnerabilities from a list. This works just fine:
^(?!.*Oracle Java.*).*$
I'm having a tough time adding another string to exclude.
I got the expression from an earlier question here:
Regular Expression to exclude set of Keywords
I've tried all the examples from this link but the answer Tim gave was the only one that worked for me.
Does anyone know how I could add another string to this?
^(?!.*Oracle Java.*).*$
You can use regex alternation inside the lookahead:
^(?!.*(Oracle Java|excluded1|excluded2).*).*$
My one of my Excel columns has more than 1000 rows records and it has records like blow
Yuichiro Sakai;#75;#Daniel Hinchcliff;#141;#Ali Reza Ehsani;#74
and another column like this:
Irene Bernabeu;#147;#Aferdita Mekuli;#139
the names comes from a database.
What I want is: How can I add a regular expression in Excel 2013 to replace substrings like ;#147;# and ;#74 with a comma?
The Excel search and replace does not support regex, but you can use place holders in your search.
Tested in Excel2010:
Search for
;#*;#
and replace with
,
for the pattern without closing ";#" you have to do a second search.
I found a great regular expression add-on for Excel it worked great
here is the link for http://www.codedawn.com/
you can use it to add regular expression in excel and solve your problem very easily
many thanks to this add-on: http://www.codedawn.com/
Use this pattern
(?>;#\d*)+
and replace with , Demo
I'm relatively new to regex and in order to set up a goal in Google Analytics, I'd like to use a regular expression to match a URL containing both "thank-you" and "purchaseisFree=False" but exclude two specific rate plans that are represented in the URL as "productRatePlanID=5197e" and "productRatePlanID=c1760".
Here is a full URL example:
https://www.examplepage.com/thank-you?productRatePlanId=5197e&purchaseIsFree=False&grossTotal=99.95&netTotal=99.95&couponCode=&invoiceNumber=INV00000589
I tried using this post as a model and created this regex:
\bthank-you\b.+\purchaseIsFree=False\b(?:$|=[^c1760]|[^5197e])
However, I'm not getting the desired results. Thanks in advance for any suggestions.
I think the below mentioned regex should solve your problem. It uses the positive|negative look ahead facility. We can sit at the beginning of http[s] and check all the three condition and then engulp the whole tree
(https?:\/\/)(?=.*?productRatePlanId=(?!5197e&)(?!c1760&))(?=.*?thank-you)(?=.*?purchaseisFree=False).*
Note:- I have used & after the productRatePlanId values just to ensure it doesnt ignore other values as 5197f, 5198d and all other sorts of values.