I am using something like this to get the text I need. how to extend this to include single quotes if the msg is 'I'hve' or O'Keefe.
regexp_replace(regexp_replace(msg string,'\n',''),'[^a-zA-Z0-9\u00E0-\u00FC""]+',' ')
I have tried \' to keep the single quote in msg string , but it errors
Related
I am trying to load some csv data to a Snowflake table. However, I am facing some issues with double double quotes in some rows of the file.
This is the file format I was using inside COPY INTO command:
file_format=(TYPE=CSV,
FIELD_DELIMITER = '|',
FIELD_OPTIONALLY_ENCLOSED_BY='"',
SKIP_HEADER =1);
As you can see in the example below, I have double double quotes around ID, which is a data quality problem, but I have to deal with it because
Column1|Column2|Column3|Column4|Column5|Column6|Column7|""ID""|Column9
I cannot change it in its source. I tried to replace the double double quotes ("") by a single double quote ("), as the below example depicts:
However, Snowflake is still returning the same error:
Found character 'I' instead of field delimiter '|' File 'XXXX', line 709, character 75 Row 708, column "Column8"["$8":8] If you would like to continue loading when an error is encountered, use other values such as 'SKIP_FILE' or 'CONTINUE' for the ON_ERROR option. For more information on loading options, please run 'info loading_data' in a SQL client.
Do you know how can I deal with this, allowing the file content to be properly loaded into Snowflake table?
I am working with a string column in redshift database where the instance of \" occurs multiple times in the same value.
I want to replace every occurrence of \" with "
For example, if a string = \"name\"
I want the output to be string = "name"
From what I have found, redshift does not allow the existence of a single backslash, and automatically converts it to a double backslash, but that is not happening in this case.
I have tried to use the REPLACE() with REPLACE( string, '\"', '"' ) but it did not have any effect. Can the string being a JSON string have any bearing on the function of REPLACE()?
I have been trying to use regexp_replace but maybe I am not using the right regular expression, hence I am not able to solve the problem.
REPLACE( string, '\\"', '"' ) seems works in this situation. I am guessing its because redshift doesn't allow a single backslash, but converts them to double backslash.
So, even though the string looked like \"name\" it was probably stored as \\"name\\" and hence putting a single backslash in the replace was not working.
EDIT: please read Bill's explanation in the comment below this reply
Im trying to use the TRIM command in SQL to Remove special characters from a string. thing is i cant seem to figure out how to remove the ' character like how when people use it in their surname.
e.g O'Reilly
in order to remove a character i have to quote it, but how can put in quotes or identify the character ' when it is used for quoting.
You want to use replace() and not trim(). Then, the escaping of single quotes requires doubling it, plus the outer single quotes. So:
replace(name, '''', '')
---------------^^ escaped single quote
--------------^--^ string delimiter for the single quote character
Use Replace function to replace that character (').
replace(name,"'","");
Link 1
Link 2
I have a string which i am getting
#set($locator=$dataElement.getLocator().get(0))
#set($selector = $locator.getSelector())
$selector is string type and it contains double quotes as well
when i am calling
executor.click(new Params("$selector",BY.$By));
selector have double quotes, which needs to be replaced with single quotes.
i tried with replacing but it is giving error
i referred question
Escaping quotes in velocity template
But this also don't solved my purpose
example
$selector can be something like
a[#href="somelink"]
and i want that to changed to
a[#href='someLink']
For velocity
$selector.replaceAll('"',"'")
replaces " with '
so something like:
executor.click(new Params("$selector.replaceAll('"',"'")",BY.$By));
this works fine
I need to include a single quote in an item transformation, like so:
<DatabaseFileNames>#(DatabaseFiles->'%(PhysicalName)', '','')</DatabaseFileNames>
This, however, spits out a rather cryptic error:
error MSB4095: The item metadata
%(PhysicalName) is being referenced
without an item name. Specify the
item name by using
%(itemname. PhysicalName).
I'm basically trying to create a comma-seperated list of single-quoted values.
How do I get single-quotes into the transformation seperator?
I tried using HTML-entities (the entity for single quote is '), like so:
<DatabaseFileNames>#(DatabaseFiles->'%(PhysicalName)', '','')</DatabaseFileNames>
But I get the same error.
It looks like you have to use URL-encoding style escapes, that is, %CharacterHexNumber. In this case, the single quote is ASCII character 39, which is 27 in hex, so the correct escape sequence is:
<DatabaseFileNames>#(DatabaseFiles->'%(PhysicalName)', '%27,%27')</DatabaseFileNames>