extract the string reg expression?
How to extract P '89' 84 of this field?CSOM 50, HON 93, P '89' 84 JASPER YOUR L
The string P I could start anywhere in the string, but is always followed by an apostrophe. It could be any length with a series of apostrophes and the years ending with a white or the end of the field.
I think that regular expressions should solve this problem, but I can't understand it. Any help is appreciated.
Hello
Here's one way:
REGEXP_SUBSTR ( txt
, 'P' || -- The letter P
'(' || -- Begin \1
'''' || -- apostophe
'[0-9]+' || -- 1 or more digits (see below for alternative)
')+' || -- End \1, which may occur 1 or more times
'( |$)' -- Either space or end-of-string
)
If the years must be exactly two digits, then change the line 5 to:
... '[0-9]{2}' || -- exactly 2 digits
Tags: Database
Similar Questions
-
Analyzes the string and extract the string delimiter
Hello
Basic questions. Is this possible with the scan of regular expression of the string to extract the string that are in the specified delimiters. Here is an example:
Name of the \\Name of the folder 1\Name to the folder 2\Name to the folder 3\File
Chain analysis can produce the following by specifying the regular expression on the right:
1 folder name
Name of the folder 2
Name of the folder 3
File name
I tried \\\%s\\%s\\%s\\%s but the %s stops on the first white space.
Thank you
Michel
RavensFan suggested the service appropriate for your condition, but you can also use an alternative, which is "spreadsheet of array of strings.
-
I'm trying to extract the strings and load them into a text-helpplease file
I'm trying to extract the strings and load them into a file text without space between them - see below
p_csa = ISCC M4 DP
where p_csa is a tring to load into a text file
Code:
SELECT SUBSTR (p_csa, 0, 0) INTO v_telco FROM DUAL;
SELECT SUBSTR (p_csa, 1, 4) INTO v_comp FROM DUAL;
SELECT SUBSTR (p_csa, 5.3) INTO v_csa_prefix FROM DUAL;
SELECT SUBSTR (p_csa, 8, 4) INTO v_csa_type FROM DUAL;
fileidinvoice: = UTL_FILE. FOPEN (c_data_location, filenameinvoice, 'W');
fileidlog: = UTL_FILE. FOPEN (c_data_location, filenamelog, 'W');
UTL_FILE. PUT_LINE)
fileidinvoice, v_telco | » '|| v_comp | "|" | v_csa_prefix: "| v_csa_type);
-the content of the file-
ISCC M4 DP
=====================
I want to remove the space between the chain above for the content of the file should look like this:
-the content of the file-
GCSIM4DPHello
976253 wrote:
I'm trying to extract the strings and load them into a file text without space between them - see belowp_csa = ISCC M4 DP
where p_csa is a tring to load into a text file
Code:
SELECT SUBSTR (p_csa, 0, 0) INTO v_telco FROM DUAL;
Is it always NULL?
SELECT SUBSTR (p_csa, 1, 4) INTO v_comp FROM DUAL;
You don't need the double table much in PL/SQL. You can simply say
v_comp := SUBSTR (p_csa, 1, 4);
Almost all integrated single-row functions work in PL/SQL. (NVL2 is the only one I know who does not work in PL/SQL).
SELECT SUBSTR (p_csa, 5.3) INTO v_csa_prefix FROM DUAL;
SELECT SUBSTR (p_csa, 8, 4) INTO v_csa_type FROM DUAL;fileidinvoice: = UTL_FILE. FOPEN (c_data_location, filenameinvoice, 'W');
fileidlog: = UTL_FILE. FOPEN (c_data_location, filenamelog, 'W');UTL_FILE. PUT_LINE)
fileidinvoice, v_telco | » '|| v_comp | "|" | v_csa_prefix: "| v_csa_type);What are you trying to do here? For example, what you're trying to put between c_comp and v_csa_prefix?
-the content of the file-
ISCC M4 DP
=====================
I want to remove the space between the chain above for the content of the file should look like this:-the content of the file-
GCSIM4DP
If you don't want space, then only concatenate all the spaces in the string before you write it and REPLACE allows you to delete all the spaces that have been copied from p_csa. For example:
UTL_FILE.PUT_LINE ( fileidinvoice , REPLACE ( v_telco || v_comp || v_csa_prefix || v_csa_type , ' ' ) );
I guess you need the v_comp of separate variables, the v_csa_prefix and the v_csa_type for something.
I hope that answers your question.
If this isn't the case, after a complete script that people can run to recreate the problem and test their ideas. Display the results you want (in other words, the contents of the file created).
Always say what version of Oracle you are using (for example, 11.2.0.3.0).
See the FAQ forum {message identifier: = 9360002} -
Extract the string from the string
Hello guys,.
I have a small question. I would like to extract a string to another string. Imagine the following string:
param1 = value1 param2 = value2, param3 = value3, param4 = value4
I would like to be able to extract value2 and value3 to this string. I know that the design of the db is not perfect and should be like this. but it is historical and I have to use this way. Any suggestion?
Thank you
to retrieve param2
Select
substr (s
, instr (s, '=', 1, 2) + 1
, instr (s, ',', 1, 2) - instr (s, '=', 1, 2) - 1
) r
from (select "param1 = value1 param2 = value2, param3 = value3, param4 = value4's double)
or
Select regexp_substr (your_string, "[^,] +' 1, 4") from your_table
for example
Select regexp_substr ("param1 = value1 param2 = value2, param3 = value3, param4 = value4 ',' [^,] +' 1, 4") param2 double
PARAM2
'value2 '.
Post edited by: chris227
Corrected solution substr (sorry was before the first coffee ;-)) -
Extract the string from the chain - separator = ' | '?
Hi people!
I want to know how to extract the a string with delimiter = XE field ' |'.
For example:
String = "field1 |" Field2 |... | fieldX |... | filedn | »
I want to extract fieldX.
Thanks for your help, regards.Use the functions like this substr and instr
substr(string, instr( string,'|', 1, xth_occurrence)+1, instr( string,'|', 1,xth_occurrence+1) - instr(string,'|', 1, xth_occurrence))
Luca
Please, mark the reply as useful/correct if it is
Published by: Luka on January 26, 2010 10:42
Published by: Luka on January 26, 2010 10:42
-
How to extract the string values
Hello
Database: 11.2.0.3.0
I have a JSON string like below. I want to extract only the propetyvalues. Can you help me with the query:
{
'documents':]
{
'document':]
{
'propertyname': 'Id',
'propertyvalue': "{1C236CB2-AB97-4982-8117-DE0BE6D7DB46}".
}
]
},
{
'document':]
{
'propertyname': 'Id',
'propertyvalue': "{1318AC90-C321-4D3D-9558-6547EFE49A7E}".
}
]
}
]
}
Hello
Too bad, that you do not have version 12. Then, you can use the function JSON_VALUE mentioned previously.
Here's something you can do in your version:
SELECT LEVEL AS n
, REGEXP_SUBSTR (: str)
, ' "propertyvalue": "([^"]*) "
1
LEVEL
NULL
1
) AS propertyvalue
OF the double
CONNECT BY LEVEL<= regexp_count="" (:str,="">=>
;
If you want to know that adapts to your specific problem, post CREATE TABLE and INSERT statements for some sample data and the exact results you want from these sample data.
-
I know that I did it in before CVI...
Only, I don't remember how I did it...
(braindead today?!?)
Here goes:
Take a string:
"Mary had a little lamb".
FindPattern "little."
resulting string: "" Mary had a lamb.
What I have works to find the model and it is place.
-sigh-
I know I'll get because from what I remember, this is a very simple solution... I can't just think of him...
And I vaguely remember the name of the function that I used...
R
You could try something like this:
-
Problem with regexp_substr if the string with null values between commas.
Hi all
My version of DB is 10.1.0.5.0
I want to extract the string values using query below, but I am unable to provide the correct result.
My required result as below.WITH t AS ( select '123,1,3,22' col FROM DUAL UNION ALL SELECT '123,,2,1' FROM DUAL UNION ALL SELECT '5,1,2,,' FROM DUAL ) SELECT regexp_substr(t.col,'[^,]*',1,1) ,regexp_substr(t.col,'[^,]*',1,2) ,regexp_substr(t.col,'[^,]*',1,3) ,regexp_substr(t.col,'[^,]*',1,4) FROM DUAL,t ;
Please help me to get the required result by using regular expressions.123 1 3 22 123 2 1 5 1 2
Thanks, RamHello
In Oracle 10, you can do so by combining REGEXP_SUBSTR with something else like RTRIM:
SELECT RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 1), ',') AS part_1 , RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 2), ',') AS part_2 , RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 3), ',') AS part_3 , RTRIM (REGEXP_SUBSTR (col, '[^,]*(,|$)', 1, 4), ',') AS part_4 FROM t ;
Starting Oracle 11 REGEXP_SUBSTR alone can do.
But look at the first response; regular expressions will be probably less effective than less powerful features, especially when all channels have the same number of separators.
Published by: Frank Kulash on 29 December 2012 08:36
-
Retrieve the string after the symbol @.
Hello
I need a suggestion how to extract the string after the symbol ' @' in the string.
The user will pass the Email that I need to extract the domain name of the string
> > Eg: [email protected]
She must return to gmail.com under the domain name, please suggest me
Thank you
SudhirTry:
select substr('[email protected]', instr('[email protected]', '@')+1) from dual
-
I haven't used regular expressions before, and I can't find a regular expression to extract a subset of the string between two markers.
The chain;
Stuff of header I want
Stuff of header I want
Stuff of header I wantStuff of header I want
Stuff of header I want
Stuff of header I want6 ERRORS
Info I want to line 1
Info I want line 2
Info I want line 3
Info I want to line 4
Info I want to line 5
Info I want line 6
END_ERRORSFrom the string above (it is read from a text file), I try to extract the subset of string between ERRORS 6 and END_ERRORS. The number of errors (6 in this case) can be any number from 1 to 32, and the number of lines I want to extract will correspond with this number. I can provide this number of a caller VI if necessary.
My current solution, which works, but is not very elegant;
(1) using Match Regular Expression for the return of the string after you have synchronized the 6 ERRORS
(2) uses the Regular Expression matches to return all characters before game END_ERRORS of the string returned by (1)
Is there a way this can be accomplished using 1 Regular Expression Match? If so someone could suggest how, as well as an explanation of the work of the given regular expression.
Thank you very much
Alan
I used a character class to catch any word or whitespace characters. This put inside parentheses a substring matching the criteria that you can get by developing the node for regular expression matching. The \d matches the numbers and the two * s repetition of the previous term. So, \d* will find the '6', as well as "123456".
-
How to extract the corresponding regex string
Hello
I am trying to extract text from a long string using QRegEx. Here's my regex:
Rx QRegExp ("^. *(192|210). * key =? *");
QString url = ""https://192.168.1.10/files/30/encrypt/key=s6h779bf " "
rx.setPatternSyntax (QRegExp::Wildcard);
rx.indexIn (str, 0);
qDebug()<>
qDebug()<>
However, it is does not match anything.
If I change the regular expression of "(192|210)." * key =? ' * ' can he match but I can't get the string after the = key
You use a regular expression capture if you want that the parameter "key."
QRegExp rx("^.*(192|210).*key=(.*)?"); qDebug() << rx.cap(1); // here's the first octet of your IP qDebug() << rx.cap(2); // key parameter (optional)
Your regex could do with a lot of improvement in my humble opinion. You might want to consuder the class QUrl that does what you want already:
QUrl url("https://192.168.1.10/files/30/encrypt/key=s6h779bf"); qDebug() << url.queryItemValue("key");
Tip: rubular is a handy Tester on the regex web which makes this kind of thing much easier to debug
-
Validate through the Reg Expression
Hello
I have following requirement through reg expressions.
Need to write a Boolean method that takes a string parameter which should satisfy following conditions.
a string of length o 20 characters.
o 9 first characters will be a number
o next 2 characters are alphabets
o characters 2 next will have a number. (1 to 31 or 99)
o 1 next character will be an alphabet
o the last 6 characters will be a number.
JDev 11.1.1.6.0You can try something like this like regex:
^+[0-9]{9}+[a-zA-Z]{2}+(0[0-9]|1[0-9]|2[0-9]|3[0-1]|99)+[a-zA-Z]{1}+[0-9]{6}$
Dario
-
Extract the substring of the string
For the life of me I can not find a function to extract a substring of an existing string. The closest I could find was SearchSplit String and replace substring, but none of them do what I want.
That's what I want to do:
Assuming that the string "Test String", the letters are in positions as follows:
T e s t _ S t r i e n t
0 1 2 3 4 5 6 7 8 9 10Now correct the substring offset 5 on position 7 (length 3):
Substring = r t S
5 6 7
In Java, for example, you can easily do this using the code below:
String str = "Test String";
Substring of String = str.substring (5.7);
There are no simple function to do this in LabVIEW? If not, what is the best way to do it?
Use String subset of index 5 and length 3.
-
Extract strings in the tdms files and write the strings in the file txt or lvm
Hi all
I'm struggling to extract strings from a file of tdms to write them in a txt file.
The strings were written in tdms is a time stamp data recorded to a compact RIO.
I put the chain in a different group from the PDM, but when I use the function read tdms with the group name, as I said, an error message is always take place.
Thanks for all the help.
PS: I have attached an example of tdms file I got over here.
Kind regards
Yifeng
I tried your attached file and it seems that everything goes file. I have attached the screenshot of my VI here, what do you want?
-
regular expression to exclude spaces in the string
Now that I'm that sleazy, I need help with a regular expression.
They must pass (or permutations it):
[00123]
[R012]
[r083]
These should fail (or permutations it):
[test]
[I was here]
[098 876]
Ooh [29873 eifvuh]]
I have most of it (the ' [' must be first; the '] "must be the last;) There must be some middle numbers, but I can't write an expression that will fail if there are 1 or more spaces in the string.
Thank you!
Tay
Several possibilities: try this regular expression.
^\[[a-za-Z]*[0-9]+[a-zA-Z0-9]*\]$
Maybe you are looking for
-
How can I open the back of my 1103735dx mini?
I need to get the serial number, and it is not obvious how to get it open!
-
pouvez the archos 101 Tablet pair with microsoft bluetooth keyboard 6000?
ARCHOS and microsoft 6000 bluetooth keyboard pouvez the archos 101 Tablet pair with microsoft bluetooth keyboard 6000? What is the genric pairing passkey?
-
videos on web pages stop playing after 5 seconds
I just installed Windows XP Home Edition on an old Dell (Dimension s 4500) computer. Most things work well; However, I notice that all the videos on websites play for about 5 seconds and then stops. The full video continues to be downloaded and can
-
Windows Movie Maker has stopped play mpg videos
Hi all I've been using Director windows for more than two years for my movie editing video canon. I always convert the canon film to video files .mpg, like this is done by one of the canon utility. After that, I import videos to movie maker window. A
-
Remember - this is a public forum so never post private information such as numbers of mail or telephone! Ideas: You have problems with programs Error messages Recent changes to your computer What you have already tried to solve the problem