Hi Splunkers,
I'm using the Website input app to scrape a page that's presented in XML. The issue is that the output contains backslashes which is not there when you load the web page in a browser. It looks like it's being put there to escape the quotes
\"info\"
Is there a way to remove the backslash?
Thanks,
dan
Resolved it. Thanks jkat54 and others for pointing me in the right direction.
Updated the props.conf file with:
[source::web_input://TestNode1]
SEDCMD-RemovingBackSlash = s/\\//g
NOTE: if you try to do this in SPL. You need 3 backslashes. It's a known thing apparently e.g.: https://answers.splunk.com/answers/24026/sedcmd-special-requirement-for-backslash.html
I've tried a bunch of different things, including all the ones suggested here, and none of them work (I'm running on 6.1.5, by the way). I can get them working in mode=sed in a splunk search rex, but not in SEDCMD. This, however totally works in SEDCMD:
SEDCMD-RemoveBackslashes = s/\x5C{1}//g
The \x5C
by itself works in ... | rex mode=sed "s/\x5C//g"
but not in SEDCMD for whatever reason. Adding the {1}
was just a shot in the dark, but it works. It also works in search with mode=sed and rex.
Resolved it. Thanks jkat54 and others for pointing me in the right direction.
Updated the props.conf file with:
[source::web_input://TestNode1]
SEDCMD-RemovingBackSlash = s/\\//g
NOTE: if you try to do this in SPL. You need 3 backslashes. It's a known thing apparently e.g.: https://answers.splunk.com/answers/24026/sedcmd-special-requirement-for-backslash.html
If you KNOW that ALL backslashes need to be removed, then you can easily remove them all. But that assumes that you want ALL the backslashes removed. If there are instances of backslashes which you want to keep, then you have to plan for that.
Removing backslashes only from before a quote might be what you want, but what if you have \"? Please provide some additional information about exactly what you need removed (and possibly why). That way he answer you get can be correct, and not "correct if and only if."
I just want to remove ALL backslashes.
Can you provide an example of the entire event (the _raw field)?
Because it's in XML, I'm having a hard time posting it here without it being interpreted. Once I click submit it removes all the tags...etc.
Here's a sample example
semaphores available=\"4\"
Returns field semaphores available=\
Have you tried SEDCMD-anyNameYouLike = s/\\"/"/g
in your props.conf?
Have you tried ... | rex "s/\\"/"/g"
in your search?
Unfortunately that regex doesn't work. Nor a modified one where I try to capture the backslash:
index=* |rex mode=sed "s/\\"/\"/g"
Doesn't remove the backslash.
OK. This works.
index=* | rex mode=sed "s/\\"/"/g"
Still giving backslashes in my 'Interesting Fields', but I'm closer to what I need now. Will work on the props.conf.
Thanks!