Search for a Word Occuring After A Non-Alphanumeric SymbolHow to remove non-alphanumeric characters?How to use '-prune' option of 'find' in sh?How do I remove all non alphanumeric characters from a string except dash?Simple regex for matching up to an optional character?How to search for word in text file and print part of line with Python?Regular Expression to Validate Plate NumberRegex - search for 2 words in a stringHow to do CamelCase split in python__pycache__ folder executes each time i run any other file in the folderRegular Expression Testing
Why can't we do three-way comparison in C++?
Why are ambiguous grammars bad?
Professor Roman loves to teach unorthodox Chemistry
How to Convert an Object into Array in magento 2
Can a Warforged suffer from magical exhaustion?
Was self-modifying code possible using BASIC?
Etymology of the expression "to entertain an idea"
If the pressure inside and outside a balloon balance, then why does air leave when it pops?
Traceroute showing inter-vlan routing?
How to show a "node near coord" even when it is out of bounds (with clip = true)?
How do I avoid typing "git" at the begining of every Git command?
Parsing text written the millitext font
How can powerful telekinesis avoid violating Newton's 3rd Law?
How does AFV select the winning videos?
What to bootstrap for hypothesis testing
What does the homotopy coherent nerve do to spaces of enriched functors?
Make Gimbap cutter
In American Politics, why is the Justice Department under the President?
Print "N NE E SE S SW W NW"
What exactly "triggers an additional time" in the interaction between Afterlife and Teysa Karlov?
Does a single fopen introduce TOCTOU vulnerability?
How (un)safe is it to ride barefoot?
one-hot-encoding categorical data gives error
What does this line mean in Zelazny's "The Courts of Chaos"?
Search for a Word Occuring After A Non-Alphanumeric Symbol
How to remove non-alphanumeric characters?How to use '-prune' option of 'find' in sh?How do I remove all non alphanumeric characters from a string except dash?Simple regex for matching up to an optional character?How to search for word in text file and print part of line with Python?Regular Expression to Validate Plate NumberRegex - search for 2 words in a stringHow to do CamelCase split in python__pycache__ folder executes each time i run any other file in the folderRegular Expression Testing
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
So I would like to re-implement todo.txt in python as a learning project. Now, I would like (for testing) that if I would add say Ask a Question on SO +StackOverFlow, I would like to reprint +StackOverflow (NOT Ask a Question on SO +StackOverflow, since Regular Expressions are the hard part, the rest is cream cheese (the rest of the owl).
I have tried to use W for this, but all Python gives me is [].
import re
todo = input("")
plusregex = re.findall("W +", todo)
print(plusregex)
Thank you for everything SO community!
regex python-3.x
add a comment |
So I would like to re-implement todo.txt in python as a learning project. Now, I would like (for testing) that if I would add say Ask a Question on SO +StackOverFlow, I would like to reprint +StackOverflow (NOT Ask a Question on SO +StackOverflow, since Regular Expressions are the hard part, the rest is cream cheese (the rest of the owl).
I have tried to use W for this, but all Python gives me is [].
import re
todo = input("")
plusregex = re.findall("W +", todo)
print(plusregex)
Thank you for everything SO community!
regex python-3.x
You should either use lookbehind or capture groups (which are more flexible).
– Mateen Ulhaq
Mar 24 at 22:55
If you are trying to extract the "tags" maybe the regular expression+[^s]+
would help? (A literal plus followed by anything but whitespace repeating)
– Jebby
Mar 24 at 23:01
re.findall(r"w+", todo)
?
– Wiktor Stribiżew
Mar 24 at 23:15
add a comment |
So I would like to re-implement todo.txt in python as a learning project. Now, I would like (for testing) that if I would add say Ask a Question on SO +StackOverFlow, I would like to reprint +StackOverflow (NOT Ask a Question on SO +StackOverflow, since Regular Expressions are the hard part, the rest is cream cheese (the rest of the owl).
I have tried to use W for this, but all Python gives me is [].
import re
todo = input("")
plusregex = re.findall("W +", todo)
print(plusregex)
Thank you for everything SO community!
regex python-3.x
So I would like to re-implement todo.txt in python as a learning project. Now, I would like (for testing) that if I would add say Ask a Question on SO +StackOverFlow, I would like to reprint +StackOverflow (NOT Ask a Question on SO +StackOverflow, since Regular Expressions are the hard part, the rest is cream cheese (the rest of the owl).
I have tried to use W for this, but all Python gives me is [].
import re
todo = input("")
plusregex = re.findall("W +", todo)
print(plusregex)
Thank you for everything SO community!
regex python-3.x
regex python-3.x
asked Mar 24 at 22:51
Ismail AhmedIsmail Ahmed
184
184
You should either use lookbehind or capture groups (which are more flexible).
– Mateen Ulhaq
Mar 24 at 22:55
If you are trying to extract the "tags" maybe the regular expression+[^s]+
would help? (A literal plus followed by anything but whitespace repeating)
– Jebby
Mar 24 at 23:01
re.findall(r"w+", todo)
?
– Wiktor Stribiżew
Mar 24 at 23:15
add a comment |
You should either use lookbehind or capture groups (which are more flexible).
– Mateen Ulhaq
Mar 24 at 22:55
If you are trying to extract the "tags" maybe the regular expression+[^s]+
would help? (A literal plus followed by anything but whitespace repeating)
– Jebby
Mar 24 at 23:01
re.findall(r"w+", todo)
?
– Wiktor Stribiżew
Mar 24 at 23:15
You should either use lookbehind or capture groups (which are more flexible).
– Mateen Ulhaq
Mar 24 at 22:55
You should either use lookbehind or capture groups (which are more flexible).
– Mateen Ulhaq
Mar 24 at 22:55
If you are trying to extract the "tags" maybe the regular expression
+[^s]+
would help? (A literal plus followed by anything but whitespace repeating)– Jebby
Mar 24 at 23:01
If you are trying to extract the "tags" maybe the regular expression
+[^s]+
would help? (A literal plus followed by anything but whitespace repeating)– Jebby
Mar 24 at 23:01
re.findall(r"w+", todo)
?– Wiktor Stribiżew
Mar 24 at 23:15
re.findall(r"w+", todo)
?– Wiktor Stribiżew
Mar 24 at 23:15
add a comment |
1 Answer
1
active
oldest
votes
The regular expression [^ws]w+
would do the trick to capture words starting with non-alphanumeric characters:
import re
todo = "Ask a Question on SO +StackOverFlow +test"
plusregex = re.findall("[^ws]w+", todo)
print(plusregex)
which outputs: ['+StackOverFlow', '@python', '!test']
Sorry for being late, but it works perfectly!
– Ismail Ahmed
Apr 7 at 22:05
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/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%2f55329347%2fsearch-for-a-word-occuring-after-a-non-alphanumeric-symbol%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
The regular expression [^ws]w+
would do the trick to capture words starting with non-alphanumeric characters:
import re
todo = "Ask a Question on SO +StackOverFlow +test"
plusregex = re.findall("[^ws]w+", todo)
print(plusregex)
which outputs: ['+StackOverFlow', '@python', '!test']
Sorry for being late, but it works perfectly!
– Ismail Ahmed
Apr 7 at 22:05
add a comment |
The regular expression [^ws]w+
would do the trick to capture words starting with non-alphanumeric characters:
import re
todo = "Ask a Question on SO +StackOverFlow +test"
plusregex = re.findall("[^ws]w+", todo)
print(plusregex)
which outputs: ['+StackOverFlow', '@python', '!test']
Sorry for being late, but it works perfectly!
– Ismail Ahmed
Apr 7 at 22:05
add a comment |
The regular expression [^ws]w+
would do the trick to capture words starting with non-alphanumeric characters:
import re
todo = "Ask a Question on SO +StackOverFlow +test"
plusregex = re.findall("[^ws]w+", todo)
print(plusregex)
which outputs: ['+StackOverFlow', '@python', '!test']
The regular expression [^ws]w+
would do the trick to capture words starting with non-alphanumeric characters:
import re
todo = "Ask a Question on SO +StackOverFlow +test"
plusregex = re.findall("[^ws]w+", todo)
print(plusregex)
which outputs: ['+StackOverFlow', '@python', '!test']
answered Mar 25 at 6:13
glhrglhr
3,3131921
3,3131921
Sorry for being late, but it works perfectly!
– Ismail Ahmed
Apr 7 at 22:05
add a comment |
Sorry for being late, but it works perfectly!
– Ismail Ahmed
Apr 7 at 22:05
Sorry for being late, but it works perfectly!
– Ismail Ahmed
Apr 7 at 22:05
Sorry for being late, but it works perfectly!
– Ismail Ahmed
Apr 7 at 22:05
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%2f55329347%2fsearch-for-a-word-occuring-after-a-non-alphanumeric-symbol%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
You should either use lookbehind or capture groups (which are more flexible).
– Mateen Ulhaq
Mar 24 at 22:55
If you are trying to extract the "tags" maybe the regular expression
+[^s]+
would help? (A literal plus followed by anything but whitespace repeating)– Jebby
Mar 24 at 23:01
re.findall(r"w+", todo)
?– Wiktor Stribiżew
Mar 24 at 23:15