I have strings like
BadRequestException("hello world")
BadRequestException(BadRequestException::$errors->message)
ConflictException(ConflictException::$errors->sldkf)
ConflictException("skdljf")
How do i add a regex that gets me these two:
ConflictException("skdljf")
BadRequestException("hello world")
I tried /Exception(/ to retrieve everything.
I could not figure out a way to eliminate those strings that contain "$errors"
I tried this:
/Exception(?!errors)/
But it did not work as per my requirements.
Thanks
Figured it out.
I used
Exception(?!.*::\$errors)
Related
I'm trying to extract the classname from a list of UE4 blueprint paths that look like this:
"Blueprint'/Game/Aberration/CoreBlueprints/Weapons/PrimalItemAmmo_Zipline.PrimalItemAmmo_Zipline'"
The end result needs to be something like this:
PrimalItemAmmo_Zipline_C
I guess the easiest way would be to extract everything between the "." and the apostrophe at the end, before appending the _C. I've tried a few different solutions I've found online, mostly modified from formulas for getting filenames from filepaths, but I can't get any of them to work properly.
What would be the best way to do this?
Assuming the string in A1, try
=substitute(regexextract(A1, "[^.]*$"), char(39)&char(34), "_C")
and see if that works?
try:
=REGEXEXTRACT(A1, "\.(.*)'")&"_C"
for array do:
=ARRAYFORMULA(IFNA(REGEXEXTRACT(A1:A, "\.(.*)'")&"_C"))
I have the following input text:
pagelimit=50&filtercolumn=Datacenter&filtervalue=abfg1&filtercolumn=MachineType&filtervalue=fg&filtercolumn=GPG&filtervalue=IPMI
I want to get back
filtercolumn=Datacenter&filtervalue=abfg1
filtercolumn=MachineType&filtervalue=fg
filtercolumn=GPG&filtervalue=IPMI
There may be an unlimited amount of these.
I have tried a few things. I'm currently trying something like this:
(?:((filtercolumn=.*&filtervalue=.*)+)?)
But of course it doesn't work. I get:
filtercolumn=Datacenter&filtervalue=abfg1&filtercolumn=MachineType&filtervalue=fg&filtercolumn=GPG&filtervalue=IPMI
filtercolumn=Datacenter&filtervalue=abfg1&filtercolumn=MachineType&filtervalue=fg&filtercolumn=GPG&filtervalue=IPMI
Try this \bfiltercolumn=[^&]*&filtervalue=[^&]*
https://regex101.com/r/sasmXL/2
Please help me in extracting the string from this text like
id1:value1,id2:value2
id1:value1a,id2:value2a
from
"[{id1:value1,id2:value2},{id1:value1a,id2:value2a}]"
{([^}]+)} will find and capture anything that is inside { }
You should include more detail in your question though and show that you have made an attempt at it yourself.
Working codes
unlist(regmatches(text, gregexpr("\\{.*?\\}", text)))
unlist(regmatches(text, gregexpr("\\{([^}]+)\\}", text)))
Got some troubles with my regex.
I got some lines like this:
SomeText#"C:\\","Shadow Copy Components:\\","E:\\",""
SomeText#"D:\\"
SomeText#"E:\\","Shadow Copy Components:\\"
SomeText#"SET SNAP_ID=serv.a.x.com_1380312019","BACKUP H:\\ USING \\\\?\\GLOBALROOT\\Device\\HarddiskVolumeShadowCopy47\\ OPTIONS:ALT_PATH_PREFIX=c:\\VERITAS\\NetBackup\\temp\\_vrts_frzn_img_3200\"
SomeText#"SET SNAP_ID=serv.a.x.com_1380312019","BACKUP Y:\\Libs USING \\\\?\\GLOBALROOT\\Device\\HarddiskVolumeShadowCopy47\\ OPTIONS:ALT_PATH_PREFIX=c:\\VERITAS\\NetBackup\\temp\\_vrts_frzn_img_3200\"
What i would like is to get a group named jobFileList containing for each line:
"C:\\","Shadow Copy Components:\\","E:\\",""
"D:\\"
"E:\\","Shadow Copy Components:\\"
H:\\
Y:\\Libs
You can see i only want the file list, but some times its only the full text after the # mark and sometimes there is a lot of ** that i need to remove.
Fact is i cant use a script for this case so i need to do this with only ONE regexp, can't just do a streplace of other stuff after the regex.
What i did is :
SomeText(#.*BACKUP (?P<jobFileList>.*?) .*)?(#(?P<jobFileList>.*))?
But seems i cant set the same GroupName :( If i replace the second jobFileList with another name its works perfectly but not what i need .
Thanks for your help,
EDIT:
I can also have some lines like :
SomeText#/ahol5d72_1_2
SomeText#/p7ol4a1p_1_2
SomeText#Gvadag04SANDsk_Daily
SomeText#/bck_reco_a9ol5765_1_2_827497669
In all these cases i need to have all the text after the # mark.
A version which doesn't rely on the double quotes after the double backslash:
SomeText#(?:(.*?BACKUP) )?(?P<jobFileList>(?(1)[^ ]*|.*$))
This: (?(1)[^ ]*|.*$) is a conditional group that is supported in Python 2.7.5 (probably works for higher versions but I don't know for previous ones). If there's BACKUP, it grabs all the non-spaces and if there's no BACKUP, it grabs everything till the end of the string.
regex101 demo
EDIT: As per comment, the regex that worked after #timmalos' modifications:
\#(?P<G>.*?[^E]BACKUP\s)?(?P<G2>f:\\\\Mailbox\\\)?(?P<jobFileList>(?(G)(?(G2)[^\]|\S)*|.*))
This is possible to match with a single regular expression however I know nothing of splunk. Maybe this will help:
("?[A-Z]:\\\\(?:".+|\S+)?)
Live demonstration here
I have a block of codes with timestamp in front of each line like this:
12/02/2010 12:20:12 function myFun()
12/02/2010 12:20:13 {....
The first column is a date time value. I would like to comment them out by using Vim, thus:
/*12/02/2010 12:20:12*/ function myFun()
/*12/02/2010 12:20:13*/ {....
I tried to search for date first:
/\d\d\/\d\d\/\d\d\d\d \d\d:\d\d:\d\d
I got all the timestamps marked correctly. However When I tried to replace them by the command:
%s/\d\d\/\d\d\/\d\d\d\d \d\d:\d\d:\d\d/\/*\d\d\/\d\d\/\d\d\d\d \d\d:\d\d:\d\d*\//
I got the following result:
/*dd/dd/dddd dd:dd:dd*/ function myFun()
/*dd/dd/dddd dd:dd:dd*/ {....
I think I need to name the search part and put them back in the replace part. How I can do it?
I suppose I would just do something like:
:%s-^../../.... ..:..:..-/* & */-
I would actually not us a regex to do this. It takes too long to enter the correct formatting. I would instead use a Visual Block. The sequence works out to be something like this.
<C-V>}I/* <ESC>
3f\s
<C-V>I */
I love regex, and don't want to knock the regex solutions, but find when doing things with pre-formatted blocks, that this is easier, and requires less of a diversion from the real task, which isn't figuring out how to write a regex.
%s/\d\d\/\d\d\/\d\d\d\d \d\d:\d\d:\d\d/\/*&*\//
:%s/^\([0-9/]* [0-9:]* \)\(.*\)/\/*\1*\/ \2/