regular expression in notepad++ - regex

I am unable to search for the following text in notepad++, I am trying to use regular expression.
Insert into SOMETABLE (COULMN1,COULMN2,COULMN3,COULMN4,COULMN5,COULMN6) values ('ANYTHING','ANYTHING',to_date('30-APR-13 18:51:41','DD-MON-RR HH24:MI:SS'),'ANYTHING',to_date('30-APR-13 18:51:41','DD-MON-RR HH24:MI:SS'),'ANYTHING');
I am trying to search to_date('30-APR-13 18:51:41','DD-MON-RR HH24:MI:SS') from the above line.

If you want to match everything from to_date( up to the closest ), search for
to_date\([^)]*\)
(using the Perl regex option).
Explanation: [^)]* matches any number of characters except ).

Related

Regular expression to replace 2023-02-06T07:43:51.9732381Z with blanks

I have a date stamp at the beginning of my log files, in the format 2023-02-06T07:43:51.9732381Z
There are other various dates, I have tried to use notepad ++ to write a regular expression to replace all the data formats with just blanks. I would like to have a regular expression to replace the dates.
Secondly, what if I wanted the dates to be in the format 2023-02-06T07:43:51 ?
To remove the leading date on every line do this:
Find what: ^2023[^ ]* (with trailing space)
Replace with: (empty string)
check the "Regular expression" radio button
To remove just the fractional seconds on every line do this:
Find what: ^(2023[^\.]*)[^ ]*
Replace with: $1
check the "Regular expression" radio button
The manual indicates
that Notepad++ uses "Boost" for regular expressions with its search syntax and replacement syntax.
So:
2023-02-06T07:43:51.9732381Z
could be matched at the start of lines by:
^\d{4}-\d\d-\d\dT\d\d:\d\d:\d\d[.]\d{7}Z
or more loosely by:
^\d+-\d+-\d+T\d+:\d+:\d+[.]\d+Z
To retain the part before the period, "mark" the sub-expression you want to keep:
^(\d+-\d+-\d+T\d+:\d+:\d+)[.]\d+Z
and refer to it in the replacement:
$1

Regex: How to find a string, then get charactes on either side up to a dilimeter?

I have a string like so:
foobar_something_alt=\"Brownfields1.png#asset:919\" /><p>MSG participat
And wish to find all oocurrences via the substring #asset: then select the characters around the match up to the quote marks.
Trying to extract specific ALT tags from a SQL dump. Is this possible with a regular expression?
Put [^"]* before and after the string you want to match. This will match any sequence of characters that aren't ".
[^"]*#asset:[^"]*

Regular expression find/replace notepad++

I've a huge text file with lines like this:
080012;Bovalino;RC;CAL;0964;89034;B098;9021;http://www.website-most.en/000/000/
And i would like extract only:
080012;***Bovalino***;***RC***;CAL;***0964***;***89034***;B098;9021;http://www.website-most.en/000/000/
And delete all other text.
Can this be done with regular expressions?
You can capture the stuff you want to keep and use a backreference in the replacement string:
Find what: ^\d*;(\w*;\w*);\w*;(\d*;\d*).*
Replace with: \1;\2
And make sure you do not tick the . matches newline option.
With Notepad++ 6 you can also use $1;$2 for the replacement (with the same meaning).
If the different fields may contain all sorts of characters and not just digits and letters, this is probably your best bet:
Find what: ^[^;]*;([^;]*;[^;]*);[^;]*;([^;]*;[^;]*).*

How to replace all words before a particular character in a line in Notepad++

How to replace all the words coming before the character '=' in every line of the code in Notepad++?
It can be done with regular expressions.
Find what: ^[\w\s]+\=(.*)$
Replace with: newword\=\1.
See the screenshot below for more information:
You should enter your desired replacement word instead of "newword" in the regular expression.

wildcard dot-star to ignore delimeter

I am trying to write a splunk query that basically extracts fields between delimiter "," and puts the value in a variable.
I want to extract everything between 2 commas.
,extract this##$,
,extract this-=##$, etc
Now, there is not an option to not give any regular expression and just get everything between , ,.
So closest I can think is ,.*, .. however .* would get greedy and match everything else.
Is there a regular expression I can use to stop wildcard matching after a , is encountered?
I tried
.*$,
.*,
which didn't work.
Not sure about splunk but in most languages you could try
/\,([^,]*)\,/
-- match all characters that aren't a comma. extraction will be in \1. Not sure if you'll need the escapes in front of the commas.
Use following regex in your splunk search query, it will extract required filed as "FIELDNAME"
| rex "(?i)\,(?P<FIELDNAME>[^ ][a-z0-9#-#$ ]+)\,\s"
Considering after "," (after field) there is space hence i have added "\s", without "\s" it will also work.