You can translate the question and the replies:

Find occurrence of a character in a string

I have similar data as below in a field. asgbf-4567-7836-001 asgbf-4568-238965-0471 uhsnfhed-248-76398-46921-89432 AA-001-567-8934-98345-200 The requirement is to find out the occurrence of '-' in the data and extract the particular substring of data. Here, there is also the need to use a case statement as the length of the data is not same and in some cases I need to extract 3rd part and in some 4th part and so on. Is there any short expression that I can use similar to **regexp_substr()**
user
03-10-2023 14:19:39 -0400
code

3 Answers

Hi, The **REGEXP** function replaces each substring of the input string that matches the given regular expression, with the given replacement.I would use this function to match the substirng provided and replace it with my desired output. The syntax for the regexp is: `REGEXP( <original text:text>, <regex:text>, <replacement:text> )` `original text`. Input string or fieldname `regex`.Regular expression to which original text is matched. `replacement`. Replacement string in regexp format. You may refer to the [**Text Processing Functions**](https://community.denodo.com/docs/html/browse/8.0/en/vdp/vql/functions/text_functions/text_functions#regexp) of the Virtual DataPort VQL Guide for more information. Hope this helps!
Denodo Team
04-10-2023 07:20:49 -0400
code
I think, this will not help me in finding the 1st, 2nd, 3rd,... occurances of '-' in the given data.
user
05-10-2023 00:23:11 -0400
Hi, In order to find out the occurrence of the '-' character in a string and display only the substring.I would either make use of the REGEXP or SPLIT function like below: For example: `select regexp('asgbf-4567-7836-6','[(.*)^-]','');` Likewise,for regexp function you could modify the display of output based on using your own regexp. `select SPLIT('-','asgbf-4567-7836-6')` In case of Split function the output is provided as an array. Furthermore,in order to identify the first position of a string or character I would also make use of the [Position](https://community.denodo.com/docs/html/browse/8.0/en/vdp/vql/functions/text_functions/text_functions#position) function.But this function is only used for identifying the position of first occurrence of a value. If you still need further assistance and if you are a user with valid support access then you can raise a support case in Denodo Support Site so that our support team can help you. Hope this helps.
Denodo Team
05-10-2023 08:23:01 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here