I'm trying to select a specific value from my column. Probably It should be done by regexp function, but I have been having some problems with that...
Column name: Column1
Is there some way to select only: sdf90df, f213jdj, kjsd2ej?
You can use this version.
select regexp_replace( Column1, '.+\\([^\\]+)\\.+', '\1' ) from yourTable
What I'm doing is selecting your Column1 with a function that does a replace based on a regular expression
The regular expression I used is
.+\\([^\\]+)\\.+ breaking it you have:
.+\\ - this gets everything until find a
\ we use two
\\ because it need to be scaped.
([^\\]+) - This portion is whithin parenthesis to be understood as a capturing group (I will talk about it later) I'm saying here get everything that isn't a
\\.+ get a dash and everything else
regexp_replace as I'm using it has this parameters:
regexp_replace(source, regex, replacement) so in my replacement I used the string
\1 which means get from that regular expression just the group 1
So, your string is
'Value\sdf90df\015' breaking it on the regular expression you have:
sdf90df which is group 1 (because of the parentesis) and then
On the first version of this answer I've used
$1 thats because some regular expression processors use it insted of
\1 but for oracle the right one is
\NUMBER to specify a capturing group.
Hope the explanation had clarify your doubts.
You can do this with
regex_substr(). Something like this:
select replace(regex_substr(column1, '[\\][^\\]+[\\]', 0, 2), '\\', '')