SQL: regex for removing certain part of a string - sql

How can I remove {color:#de350b} and {color} from:
{color:#de350b}FA_RDA_CORE-DEC-20220325122114-210-981{color}
to get:
FA_RDA_CORE-DEC-20220325122114-210-981

Good day.
Can you try this? Please don't forget substitution with "$5".
Regex101ttps://regex101.com/r/aDJzUf/1

Related

How to search splunk query which includes double quotes in the string to search

I am trying to search for a pattern(see below) in the logs using splunk. The String which I am going to search includes double quotes.
Below info log is printed in the logger..
INFO: o.l.k.SomeClass: {"function": "delete", "tenenId":"15897",.......}
And the string i want to search is
"function": "delete"
The splunk query I am trying to execute is.,
index="12585" "\"function\": \"delete\""
I am not quite sure if this is going to work. Any suggestions?
There are probably multiple whitespace characters between functionand delete. I suggest you just search for the two phrases separately, rather than together
index="12585" \"function\": \"delete\"
Since your data is in raw format, you can look if the "function" field is automatically extracted by Splunk. If yes, you can simply search for index="index_1" function="delete" else, you can search for index="index_1" "function" "delete" as is, and Splunk will search for function and delete in your raw event.
I was researching for a similar problem where I need to search for exact string match which includes double quotes. It doesn't look like we can directly query with escaped double quote. So we have to use regex.
In your scenario, you could try this query:
index="12585" | regex fieldname=".*\"function\": \"delete\".*"
It will try to run regex match on the fieldname. The regex can be validated in any online regex tester.
I haven't figured out how to query with _raw field. Doing _raw=".*\\\"delete\\\".*" doesn't seem to be returning anything..

I am trying to create a URL but the URL must contain \r\n

I have been beating my head against the wall with this one. The url must contain \r\n at the end or the device I am connecting to will not recognise it. I did not create the device so I can't go in and change what it is looking for. I also can not use the percent values for them either. When I create the URL from a string the URL becomes nil because it does not like the \r\n. I have searched on here all day. Literally and have come up with nothing. If anyone has a suggestion please let me know. I would really appreciate it.
Edit.. The url is #"http://192.168.1.1/link.html?cmd=scan\r\n"
I was able to figure out another way in so I did not have to send the string like that. Thank for the help.
Try this:
NSLog(#"http://192.168.1.1/link.html?cmd=scan\\r\\n");
OutPut:
http://192.168.1.1/link.html?cmd=scan\r\n
You have to skip the "\" with just putting another "\".

Thymeleaf compare #locale expression object with string

I want to set a th:class attribute depending on the context locale using the expression object #locale.
I have tried
th:class="${#locale}=='en'?'active':''"
th:class="${#locale=='en'}?'active':''"
Both of them results in false, but whent I print it with th:text="${#locale}, I got the correct locale code (en,es).
Any idea of how to compare the #locale object with a locale code?
Based on the answer posted by David_Garcia, I could resolve my issue this way:
th:class="__${#locale}__=='en'?'active':''
This is a issue that I told to the guys of thymeleaf time ago.
You need to resolve first the #locale before comparing it with "en".
You can do that adding 2 underscore at the beggining and end to the expresion that you want to resolve first. In your case will be something like this:
th:call="$({__#locale__}=='en'?'active':'')"
I used like this
th:text="${#locale.toString()}=='in'?'active':'inactive'"

Non-greedy regex match when searching from end

I read that you should use ? to match text non-greedily, so the regex
http://.*?\.png
...used on
http://example.png.png
...would return http://example.png.
But the non-greediness only seems to work from left to right. That is, if I matched it on
http://http://example.png
...it would return http://http://example.png.
How can I get the code to match http://example.png only?
Try this:
http://[A-Za-z0-9_-]+\.png
It wont get the first http:// because it has more than [A-Za-z0-9_-]+ between it and .png
Could also use this if you are worried about other characters in the URL:
http://[^:]+?\.png
You could use a negative look ahead too, but I think smerny 's answer is better.
http://(?!http://).*?\.png

How to cut a String in VB.NET?

I have that string ...
C:\Users\ApplicationData\Folder1\Myapp.exe
How could i cut like:
C:\Users\ApplicationData\Folder1
I have tried s.split("\Myapp.exe") , where s is C:\Users\ApplicationData\Folder1\Myapp.exe
Plase help me, thanks.
Use the Path class:
Path.GetDirectoryName("C:\Users\ApplicationData\Folder1\Myapp.exe")
Check it here:
http://msdn.microsoft.com/en-us/library/system.io.path.getdirectoryname.aspx
you can use the System.IO.FileInfo class.
It contains a function FullName, which returns the directory full name.
check this link