regexp_replace get specific character after single quotes and space
I am not that good in regex but I want to catch a specific word after Info_type
, so the result would be DATABASE
or APPLICATION
or MOBILE
.
example:
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="10:00:10" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""APPLICATION""" Starting="07:00:30" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""MOBILE""" Starting="02:00:20" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
edit:
I have some other data like this :
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE A""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
I tried SELECT REGEXP_REPLACE(name, '(.*)(Info_type=)') FROM TAB1
sql oracle
add a comment |
I am not that good in regex but I want to catch a specific word after Info_type
, so the result would be DATABASE
or APPLICATION
or MOBILE
.
example:
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="10:00:10" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""APPLICATION""" Starting="07:00:30" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""MOBILE""" Starting="02:00:20" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
edit:
I have some other data like this :
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE A""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
I tried SELECT REGEXP_REPLACE(name, '(.*)(Info_type=)') FROM TAB1
sql oracle
What’s with the triple quotation marks?
– Joakim Danielson
Nov 14 '18 at 8:41
@JoakimDanielson I didn't understand , these texts are inserted from the application
– Baalback
Nov 14 '18 at 8:47
add a comment |
I am not that good in regex but I want to catch a specific word after Info_type
, so the result would be DATABASE
or APPLICATION
or MOBILE
.
example:
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="10:00:10" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""APPLICATION""" Starting="07:00:30" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""MOBILE""" Starting="02:00:20" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
edit:
I have some other data like this :
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE A""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
I tried SELECT REGEXP_REPLACE(name, '(.*)(Info_type=)') FROM TAB1
sql oracle
I am not that good in regex but I want to catch a specific word after Info_type
, so the result would be DATABASE
or APPLICATION
or MOBILE
.
example:
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="10:00:10" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""APPLICATION""" Starting="07:00:30" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""MOBILE""" Starting="02:00:20" Ending=""0000"" Comments="""NONE"""
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
edit:
I have some other data like this :
Flyfast,unix.system,1-1-1,""Table X"" D-Day=""Flood"" id =123123PTIWQ Type='A' info_name=""Fast"" Info_type="""DATABASE A""" Starting="00:00:10" Ending=""0000"" Comments="""NONE"""
I tried SELECT REGEXP_REPLACE(name, '(.*)(Info_type=)') FROM TAB1
sql oracle
sql oracle
edited Nov 14 '18 at 9:20
Baalback
asked Nov 14 '18 at 8:39
BaalbackBaalback
305417
305417
What’s with the triple quotation marks?
– Joakim Danielson
Nov 14 '18 at 8:41
@JoakimDanielson I didn't understand , these texts are inserted from the application
– Baalback
Nov 14 '18 at 8:47
add a comment |
What’s with the triple quotation marks?
– Joakim Danielson
Nov 14 '18 at 8:41
@JoakimDanielson I didn't understand , these texts are inserted from the application
– Baalback
Nov 14 '18 at 8:47
What’s with the triple quotation marks?
– Joakim Danielson
Nov 14 '18 at 8:41
What’s with the triple quotation marks?
– Joakim Danielson
Nov 14 '18 at 8:41
@JoakimDanielson I didn't understand , these texts are inserted from the application
– Baalback
Nov 14 '18 at 8:47
@JoakimDanielson I didn't understand , these texts are inserted from the application
– Baalback
Nov 14 '18 at 8:47
add a comment |
1 Answer
1
active
oldest
votes
Here is how to extract the word and I assume it is always surrounded by triple quotation marks
SELECT REGEXP_REPLACE(name, '^.*Info_type="""([A-Z ]*)""".*', '1')
FROM tab1
Update
This version is more flexible and allows for 1-3 quotation marks around the word
SELECT REGEXP_REPLACE(name, '^.*Info_type=["]{1,3}([A-Z ]*)["]{1,3}.*', '1')
FROM tab1
Update 2
Allowed for the word to contain space
not always surrounded by triple quotes, sometimes 1 doublequote, is it possible to get the space after the double quote
– Baalback
Nov 14 '18 at 8:59
@Baalback What space, do you mean the one before the word 'Spacing'?
– Joakim Danielson
Nov 14 '18 at 9:02
I mean before the wordstarting
Note not always there is world starting
– Baalback
Nov 14 '18 at 9:04
@Baalback You asked one thing and now you're changing the question, if you always want an extra space before or after then add it to the last argument of REGEXP_REPLACE like'1 '
to get a trailing space.
– Joakim Danielson
Nov 14 '18 at 9:07
I appreciate your help but I noticed in some of my data contains space for example ""DATABASE A"" how to treat that ? I have large data that's why I didn't notice it
– Baalback
Nov 14 '18 at 9:19
|
show 4 more comments
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296008%2fregexp-replace-get-specific-character-after-single-quotes-and-space%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Here is how to extract the word and I assume it is always surrounded by triple quotation marks
SELECT REGEXP_REPLACE(name, '^.*Info_type="""([A-Z ]*)""".*', '1')
FROM tab1
Update
This version is more flexible and allows for 1-3 quotation marks around the word
SELECT REGEXP_REPLACE(name, '^.*Info_type=["]{1,3}([A-Z ]*)["]{1,3}.*', '1')
FROM tab1
Update 2
Allowed for the word to contain space
not always surrounded by triple quotes, sometimes 1 doublequote, is it possible to get the space after the double quote
– Baalback
Nov 14 '18 at 8:59
@Baalback What space, do you mean the one before the word 'Spacing'?
– Joakim Danielson
Nov 14 '18 at 9:02
I mean before the wordstarting
Note not always there is world starting
– Baalback
Nov 14 '18 at 9:04
@Baalback You asked one thing and now you're changing the question, if you always want an extra space before or after then add it to the last argument of REGEXP_REPLACE like'1 '
to get a trailing space.
– Joakim Danielson
Nov 14 '18 at 9:07
I appreciate your help but I noticed in some of my data contains space for example ""DATABASE A"" how to treat that ? I have large data that's why I didn't notice it
– Baalback
Nov 14 '18 at 9:19
|
show 4 more comments
Here is how to extract the word and I assume it is always surrounded by triple quotation marks
SELECT REGEXP_REPLACE(name, '^.*Info_type="""([A-Z ]*)""".*', '1')
FROM tab1
Update
This version is more flexible and allows for 1-3 quotation marks around the word
SELECT REGEXP_REPLACE(name, '^.*Info_type=["]{1,3}([A-Z ]*)["]{1,3}.*', '1')
FROM tab1
Update 2
Allowed for the word to contain space
not always surrounded by triple quotes, sometimes 1 doublequote, is it possible to get the space after the double quote
– Baalback
Nov 14 '18 at 8:59
@Baalback What space, do you mean the one before the word 'Spacing'?
– Joakim Danielson
Nov 14 '18 at 9:02
I mean before the wordstarting
Note not always there is world starting
– Baalback
Nov 14 '18 at 9:04
@Baalback You asked one thing and now you're changing the question, if you always want an extra space before or after then add it to the last argument of REGEXP_REPLACE like'1 '
to get a trailing space.
– Joakim Danielson
Nov 14 '18 at 9:07
I appreciate your help but I noticed in some of my data contains space for example ""DATABASE A"" how to treat that ? I have large data that's why I didn't notice it
– Baalback
Nov 14 '18 at 9:19
|
show 4 more comments
Here is how to extract the word and I assume it is always surrounded by triple quotation marks
SELECT REGEXP_REPLACE(name, '^.*Info_type="""([A-Z ]*)""".*', '1')
FROM tab1
Update
This version is more flexible and allows for 1-3 quotation marks around the word
SELECT REGEXP_REPLACE(name, '^.*Info_type=["]{1,3}([A-Z ]*)["]{1,3}.*', '1')
FROM tab1
Update 2
Allowed for the word to contain space
Here is how to extract the word and I assume it is always surrounded by triple quotation marks
SELECT REGEXP_REPLACE(name, '^.*Info_type="""([A-Z ]*)""".*', '1')
FROM tab1
Update
This version is more flexible and allows for 1-3 quotation marks around the word
SELECT REGEXP_REPLACE(name, '^.*Info_type=["]{1,3}([A-Z ]*)["]{1,3}.*', '1')
FROM tab1
Update 2
Allowed for the word to contain space
edited Nov 14 '18 at 9:42
answered Nov 14 '18 at 8:55
Joakim DanielsonJoakim Danielson
7,6103724
7,6103724
not always surrounded by triple quotes, sometimes 1 doublequote, is it possible to get the space after the double quote
– Baalback
Nov 14 '18 at 8:59
@Baalback What space, do you mean the one before the word 'Spacing'?
– Joakim Danielson
Nov 14 '18 at 9:02
I mean before the wordstarting
Note not always there is world starting
– Baalback
Nov 14 '18 at 9:04
@Baalback You asked one thing and now you're changing the question, if you always want an extra space before or after then add it to the last argument of REGEXP_REPLACE like'1 '
to get a trailing space.
– Joakim Danielson
Nov 14 '18 at 9:07
I appreciate your help but I noticed in some of my data contains space for example ""DATABASE A"" how to treat that ? I have large data that's why I didn't notice it
– Baalback
Nov 14 '18 at 9:19
|
show 4 more comments
not always surrounded by triple quotes, sometimes 1 doublequote, is it possible to get the space after the double quote
– Baalback
Nov 14 '18 at 8:59
@Baalback What space, do you mean the one before the word 'Spacing'?
– Joakim Danielson
Nov 14 '18 at 9:02
I mean before the wordstarting
Note not always there is world starting
– Baalback
Nov 14 '18 at 9:04
@Baalback You asked one thing and now you're changing the question, if you always want an extra space before or after then add it to the last argument of REGEXP_REPLACE like'1 '
to get a trailing space.
– Joakim Danielson
Nov 14 '18 at 9:07
I appreciate your help but I noticed in some of my data contains space for example ""DATABASE A"" how to treat that ? I have large data that's why I didn't notice it
– Baalback
Nov 14 '18 at 9:19
not always surrounded by triple quotes, sometimes 1 doublequote, is it possible to get the space after the double quote
– Baalback
Nov 14 '18 at 8:59
not always surrounded by triple quotes, sometimes 1 doublequote, is it possible to get the space after the double quote
– Baalback
Nov 14 '18 at 8:59
@Baalback What space, do you mean the one before the word 'Spacing'?
– Joakim Danielson
Nov 14 '18 at 9:02
@Baalback What space, do you mean the one before the word 'Spacing'?
– Joakim Danielson
Nov 14 '18 at 9:02
I mean before the word
starting
Note not always there is world starting– Baalback
Nov 14 '18 at 9:04
I mean before the word
starting
Note not always there is world starting– Baalback
Nov 14 '18 at 9:04
@Baalback You asked one thing and now you're changing the question, if you always want an extra space before or after then add it to the last argument of REGEXP_REPLACE like
'1 '
to get a trailing space.– Joakim Danielson
Nov 14 '18 at 9:07
@Baalback You asked one thing and now you're changing the question, if you always want an extra space before or after then add it to the last argument of REGEXP_REPLACE like
'1 '
to get a trailing space.– Joakim Danielson
Nov 14 '18 at 9:07
I appreciate your help but I noticed in some of my data contains space for example ""DATABASE A"" how to treat that ? I have large data that's why I didn't notice it
– Baalback
Nov 14 '18 at 9:19
I appreciate your help but I noticed in some of my data contains space for example ""DATABASE A"" how to treat that ? I have large data that's why I didn't notice it
– Baalback
Nov 14 '18 at 9:19
|
show 4 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53296008%2fregexp-replace-get-specific-character-after-single-quotes-and-space%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
What’s with the triple quotation marks?
– Joakim Danielson
Nov 14 '18 at 8:41
@JoakimDanielson I didn't understand , these texts are inserted from the application
– Baalback
Nov 14 '18 at 8:47