This question already has an answer here:
Extracting a numerical value from a paragraph based on preceding words
(1 answer)
Closed 2 years ago.
I wanted to extract string between = and & using REGEXP_EXTRACT in Presto.
I did
select REGEXP_EXTRACT('blogId=abcde&logNo=222014685296','blogID=(.*)&');
but it returns NULL.
The result I want to get is 'abcde' here.
Could you help me out?
Thank you
Regex is usually case sensitive and have blogId in your input string and blogID in your pattern.
Related
This question already has answers here:
Turning a Comma Separated string into individual rows
(16 answers)
Closed 2 years ago.
NOIDEHOB_NOIDE1_4321-123
i want to create a querie that extract the following values from the example above:
NOIDEHOB
NOIDE1
4321-123
I need to base the query on the sign _. The values NOIDEHOB, NOIDE1 and 4321-123 are dynamic and the length will vary. There will never be any other _ sign in the string.
Any suggestions?
You can use string_split():
select s.value
from string_split('NOIDEHOB_NOIDE1_4321-123', '_') s
This question already has an answer here:
Reference - What does this regex mean?
(1 answer)
Closed 3 years ago.
I have to put a string after every 5 characters in a given string (varchar2).
Given string can have different length.
I already solved it by a loop using substrings.
Is there any way i could reach the goal using REGEXP in Oracle DB?
You can use REGEXP_REPLACE to replace every 5 characters with those 5 characters followed by another string. For example:
SELECT REGEXP_REPLACE('ABCDE12345FGHIJ67890KL', '(.{5})', '\1*') FROM DUAL
Output:
ABCDE*12345*FGHIJ*67890*KL
Demo on dbfiddle
This question already has answers here:
Split string and take last element
(15 answers)
Closed 6 years ago.
i have a string like that $TAOVV*NK_LFE_11029_41586 and i want to select only 11029, the number between _. I try with
substring([OrderCode],PatIndex('%_[0-9]_%', [OrderCode]),LEN([OrderCode]))
but not extract only that number.How i can define the length that change and it's not always of 5 characters as in this example?
You need to do the substring twice..
Try with this
declare #code nvarchar(100)='$TAOVV*NK_LFE_11029_41586'
select substring(substring(#code,PatIndex('%_[0-9]_%', #code)+1,LEN(#code)),1,charindex('_',substring(#code,PatIndex('%_[0-9]_%', #code)+1,LEN(#code)))-1)
This question already has an answer here:
Converting special character to plain text in oracle
(1 answer)
Closed 5 years ago.
I'm a new SQL user, and I'd like to know if there is a simple way of replacing non-English characters in Oracle SQl-developer. Let's Say, I want Hernán Nuñez to show up as Hernan Nunez, but without having to actually replace "Hernán" with "Hernan". What I need is to replace everything that contains "á" to the same thing, but with "a" instead, for example. Any suggestions?
US7ASCII will give you the right result. Example:
SELECT CONVERT('BESANÇON','US7ASCII')
FROM table;
CONVERT(
--------
BESANCON
1 row selected.
This question already has answers here:
How to get rightmost 10 places of a string in oracle
(5 answers)
Closed 8 years ago.
I have a table containing the following fields:
version
id
set_value
marker
I want to write a SELECT statement to query them. However, the values in the column marker are not easily readable. I would like to present a substring of that column. My question is how do I do this?
You can use this:
SELECT version,
id,
set_value,
SUBSTR(marker, 1, 10) AS marker
FROM ...
to select just the first ten characters of marker, and still have the resulting column be named "marker".
(See http://docs.oracle.com/cd/B28359_01/server.111/b28286/functions169.htm.)
You can use the substr function.