Retrieve regex full matchRegex for numbers onlyHow do I return multiple values from a function?Regular expression to match a line that doesn't contain a wordHow do you access the matched groups in a JavaScript regular expression?How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?Converting user input string to regular expressionRegEx match open tags except XHTML self-contained tagsPython progression path - From apprentice to guruRegEx to extract all matches from string using RegExp.execString split with regex, return array with full matches
Do wheelchair aircraft exist?
12TET vs Pythagorean scales; "perfect" fourths?
2000s Animated TV show where teenagers could physically go into a virtual world
Social leper versus social leopard
Examples of "unsuccessful" theories with afterlives
Is it impolite to ask for halal food when traveling to and in Thailand?
Meaning of 'ran' in German?
Co-Supervisor comes to office to help her students which distracts me
Is this Portent-like spell balanced?
Meaning of 小せェサル in the following sentence
Hiking with a mule or two?
To what extent is it worthwhile to report check fraud / refund scams?
What exactly did this mechanic sabotage on the American Airlines 737, and how dangerous was it?
Lettrine + string manipulation + some fonts = errors and weird issues
Is there any iPhone SE out there with 3D Touch?
How can an attacker use robots.txt?
What is the need of methods like GET and POST in the HTTP protocol?
Safely hang a mirror that does not have hooks
Does Sitecore have support for Sitecore products in containers?
Can a broken/split chain be reassembled?
Is it really necessary to have a four hour meeting in Sprint planning?
practicality of 30 year fix mortgage at 55 years of age
A delve into extraordinary chess problems: Selfmate 1
Should the average user with no special access rights be worried about SMS-based 2FA being theoretically interceptable?
Retrieve regex full match
Regex for numbers onlyHow do I return multiple values from a function?Regular expression to match a line that doesn't contain a wordHow do you access the matched groups in a JavaScript regular expression?How can I match multiple occurrences with a regex in JavaScript similar to PHP's preg_match_all()?Converting user input string to regular expressionRegEx match open tags except XHTML self-contained tagsPython progression path - From apprentice to guruRegEx to extract all matches from string using RegExp.execString split with regex, return array with full matches
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I'm new in regex expressions. I've read the documentation but I still have some questions.
I Have the following string:
[('15000042', 19)]
And I need to get the key, the comma and the value as a string.
like this:
15000042,19
I need this to enter these value as a comma separated value in a database.
I've tried the next regular expression:
([w,]+)
but this only split the string into 3 substrings. Is there a way to get the full match?
https://regex101.com/r/vtYKOG/1
I'm using python
python regex python-3.x python-3.7
add a comment
|
I'm new in regex expressions. I've read the documentation but I still have some questions.
I Have the following string:
[('15000042', 19)]
And I need to get the key, the comma and the value as a string.
like this:
15000042,19
I need this to enter these value as a comma separated value in a database.
I've tried the next regular expression:
([w,]+)
but this only split the string into 3 substrings. Is there a way to get the full match?
https://regex101.com/r/vtYKOG/1
I'm using python
python regex python-3.x python-3.7
add a comment
|
I'm new in regex expressions. I've read the documentation but I still have some questions.
I Have the following string:
[('15000042', 19)]
And I need to get the key, the comma and the value as a string.
like this:
15000042,19
I need this to enter these value as a comma separated value in a database.
I've tried the next regular expression:
([w,]+)
but this only split the string into 3 substrings. Is there a way to get the full match?
https://regex101.com/r/vtYKOG/1
I'm using python
python regex python-3.x python-3.7
I'm new in regex expressions. I've read the documentation but I still have some questions.
I Have the following string:
[('15000042', 19)]
And I need to get the key, the comma and the value as a string.
like this:
15000042,19
I need this to enter these value as a comma separated value in a database.
I've tried the next regular expression:
([w,]+)
but this only split the string into 3 substrings. Is there a way to get the full match?
https://regex101.com/r/vtYKOG/1
I'm using python
python regex python-3.x python-3.7
python regex python-3.x python-3.7
asked Mar 28 at 17:01
Javier RamirezJavier Ramirez
521 silver badge7 bronze badges
521 silver badge7 bronze badges
add a comment
|
add a comment
|
1 Answer
1
active
oldest
votes
You match what you don't want to keep and use 3 groups instead of 1 and assemble your value using these 3 groups:
[('(d+)'(,) (d+))]
Regex demo
For example:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[('(d+)'(,) (d+))]", r"123", test_str)
if result:
print (result)
Result
15000042,19
Another option is to use only your character class [^w,]+
and negate it so match not what is listed.
Then replace those characters with an empty string:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[^w,]+", "", test_str)
if result:
print (result)
Regex demo
1
Thank you very much, I think is better the second case since it fits my needs.
– Javier Ramirez
Mar 28 at 17:44
add a comment
|
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/4.0/"u003ecc by-sa 4.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%2f55403179%2fretrieve-regex-full-match%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
You match what you don't want to keep and use 3 groups instead of 1 and assemble your value using these 3 groups:
[('(d+)'(,) (d+))]
Regex demo
For example:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[('(d+)'(,) (d+))]", r"123", test_str)
if result:
print (result)
Result
15000042,19
Another option is to use only your character class [^w,]+
and negate it so match not what is listed.
Then replace those characters with an empty string:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[^w,]+", "", test_str)
if result:
print (result)
Regex demo
1
Thank you very much, I think is better the second case since it fits my needs.
– Javier Ramirez
Mar 28 at 17:44
add a comment
|
You match what you don't want to keep and use 3 groups instead of 1 and assemble your value using these 3 groups:
[('(d+)'(,) (d+))]
Regex demo
For example:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[('(d+)'(,) (d+))]", r"123", test_str)
if result:
print (result)
Result
15000042,19
Another option is to use only your character class [^w,]+
and negate it so match not what is listed.
Then replace those characters with an empty string:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[^w,]+", "", test_str)
if result:
print (result)
Regex demo
1
Thank you very much, I think is better the second case since it fits my needs.
– Javier Ramirez
Mar 28 at 17:44
add a comment
|
You match what you don't want to keep and use 3 groups instead of 1 and assemble your value using these 3 groups:
[('(d+)'(,) (d+))]
Regex demo
For example:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[('(d+)'(,) (d+))]", r"123", test_str)
if result:
print (result)
Result
15000042,19
Another option is to use only your character class [^w,]+
and negate it so match not what is listed.
Then replace those characters with an empty string:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[^w,]+", "", test_str)
if result:
print (result)
Regex demo
You match what you don't want to keep and use 3 groups instead of 1 and assemble your value using these 3 groups:
[('(d+)'(,) (d+))]
Regex demo
For example:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[('(d+)'(,) (d+))]", r"123", test_str)
if result:
print (result)
Result
15000042,19
Another option is to use only your character class [^w,]+
and negate it so match not what is listed.
Then replace those characters with an empty string:
import re
test_str = "[('15000042', 19)]"
result = re.sub(r"[^w,]+", "", test_str)
if result:
print (result)
Regex demo
edited Mar 28 at 17:36
answered Mar 28 at 17:27
The fourth birdThe fourth bird
41.1k9 gold badges20 silver badges37 bronze badges
41.1k9 gold badges20 silver badges37 bronze badges
1
Thank you very much, I think is better the second case since it fits my needs.
– Javier Ramirez
Mar 28 at 17:44
add a comment
|
1
Thank you very much, I think is better the second case since it fits my needs.
– Javier Ramirez
Mar 28 at 17:44
1
1
Thank you very much, I think is better the second case since it fits my needs.
– Javier Ramirez
Mar 28 at 17:44
Thank you very much, I think is better the second case since it fits my needs.
– Javier Ramirez
Mar 28 at 17:44
add a comment
|
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%2f55403179%2fretrieve-regex-full-match%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