2

My dataset contains special characters. I want to identify the data which contains special characters and separate it into a new column.

List of special characters :

`~!@#$%^&*_{}[]<>?/

Below are examples of the data:

enter image description here

I want the data to be separated as the above mentioned table, is there any way to do it?

3
  • regexp_match regexp_substr try something
    – BERA
    Jan 26 at 13:10
  • 6
    What is, in your example, a "special character? Is it the @? Is it the apostrophe? I'm afraid you cannot filter by "special character " without defining first what a special character is.
    – Trikelians
    Jan 26 at 13:11
  • 1
    Apart from the question what a specil character is, you should also make clear what exaclty the result should look like. Which part of the string do you want to "separate into a new column", e.g. using your first example 1.KFC@Hyderabad-Hitech city. Best would be to show us how the results from your list of examples should look like.
    – Babel
    Jan 26 at 15:13

2 Answers 2

3

There is a discrepancy between the list of special characters and the example. Specifically, a single quote or apostrophe isn't in the list, but yet Burgers's in the example is supposed to be caught by the filter.

My impression is that only a space and letters, possibly a hyphen/minus, should be excluded and everything else considered "special":

case
when regexp_match("Content", '[^\\p{L} ]') then "Content"
end

If you want to exclude numbers as well, then go with the following:

case
when regexp_match("Content", '[^\\p{L}\\p{N} ]') then "Content"
end
2

Use this expression. It copies the content of attribute field text if it contains everything else than characters a-z (upper- and lowercase), numbers or whitespaces (if needed, add further values you want to treat as regular/non-special character after \\s):

case 
when regexp_match ("text",'([^a-zA-Z0-9\\s])') > 0
then "text"
end

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.