Apparently this is not easy! There's got to be a way using pure regex?? I just know there is....
I have found a way to select the text after the first occurrence of a hyphen in a text file
Unique Thing - Some Text
Another Thing - Some Text again
Some Thing - Some more text
But I only want the right side of the hyphen.. Anyone know a quick regex to acplish this?
To be clear, given text above i want
Some Text
Some Text again
Some more text
Thanks ya'll
UPDATE: Maybe it would help with an actual chunk of text. This is from the most recent live stream chat for the whitehouse press briefing Aug 2, 2017.
Hernando Arce - build the wall with solar panels,
Christmas Girl - Let's do our own quick internet poll on live chat. Ready........Good with new immigrating into the US policy he is talking about. YES or NO,
ART - AMEN,
coffeefish - Stop H1B visa corruption!,
CarollDelMuro .Arbonne - Red,
Legion - BUILD THE WALL!,
wass sabi - MAGA,
Yokoshima - I live in Florida. Speaking English isn't racist. If you've ever been to Miami, you would know why it's needed.,
Home O'DFree - NO the campaign was BUILD THE WALL,
Melissa Renee - is he on benzos,
Paid Observer - kim jung un vs Trump in basketball,
Selina Serrano - polling data,
zonnekat - aliens....,
Farrah - NFL ,
Selina Serrano - massive,
Glenda Greene - MAGA,
Christoph Schneider - who would ever e to USA when they get lower pays? Russians?,
Carolyn Hall - MAGA MAGA MAGA ,
Sandra Honeyman - Isn't limiting immigration to skilled workers going to displace more skilled American workers?,
Mike Hancock - AMERICA FIRST,
Adnan Khan - Send them back to Mars,
Paid Observer - wtf is that,
GDot - THIS BETTER PASS OR THERE SHALL BE HANGINGS,
Null_Mage - This man is more attractive than Sarah,
monkeygraborange - FUCK CONGRESS,
Selina Serrano - personal,
This is the text i'm testing in regex101.
^[^-]*[^ -]
does not seem to work here.
I do like the few suggestions about splitting line by line then matching however, the chat stream is many thousands of lines. The end result of all this is counting occurrences of words. For anyone whos interested the repo is I just pushed the logs from the latest press briefing.
Apparently this is not easy! There's got to be a way using pure regex?? I just know there is....
I have found a way to select the text after the first occurrence of a hyphen in a text file
Unique Thing - Some Text
Another Thing - Some Text again
Some Thing - Some more text
But I only want the right side of the hyphen.. Anyone know a quick regex to acplish this?
To be clear, given text above i want
Some Text
Some Text again
Some more text
Thanks ya'll
UPDATE: Maybe it would help with an actual chunk of text. This is from the most recent live stream chat for the whitehouse press briefing Aug 2, 2017.
Hernando Arce - build the wall with solar panels,
Christmas Girl - Let's do our own quick internet poll on live chat. Ready........Good with new immigrating into the US policy he is talking about. YES or NO,
ART - AMEN,
coffeefish - Stop H1B visa corruption!,
CarollDelMuro .Arbonne - Red,
Legion - BUILD THE WALL!,
wass sabi - MAGA,
Yokoshima - I live in Florida. Speaking English isn't racist. If you've ever been to Miami, you would know why it's needed.,
Home O'DFree - NO the campaign was BUILD THE WALL,
Melissa Renee - is he on benzos,
Paid Observer - kim jung un vs Trump in basketball,
Selina Serrano - polling data,
zonnekat - aliens....,
Farrah - NFL ,
Selina Serrano - massive,
Glenda Greene - MAGA,
Christoph Schneider - who would ever e to USA when they get lower pays? Russians?,
Carolyn Hall - MAGA MAGA MAGA ,
Sandra Honeyman - Isn't limiting immigration to skilled workers going to displace more skilled American workers?,
Mike Hancock - AMERICA FIRST,
Adnan Khan - Send them back to Mars,
Paid Observer - wtf is that,
GDot - THIS BETTER PASS OR THERE SHALL BE HANGINGS,
Null_Mage - This man is more attractive than Sarah,
monkeygraborange - FUCK CONGRESS,
Selina Serrano - personal,
This is the text i'm testing in regex101.
^[^-]*[^ -]
does not seem to work here.
I do like the few suggestions about splitting line by line then matching however, the chat stream is many thousands of lines. The end result of all this is counting occurrences of words. For anyone whos interested the repo is https://github./archae0pteryx/yt-live-chat-scraper I just pushed the logs from the latest press briefing.
Share Improve this question edited Aug 2, 2017 at 20:36 rimraf asked Aug 2, 2017 at 19:40 rimrafrimraf 4,1377 gold badges32 silver badges56 bronze badges 4-
2
Why use regex?
str.split("-")[1]
should work. – Khauri Commented Aug 2, 2017 at 19:43 - Where is your code? What doesn't work? – Toto Commented Aug 2, 2017 at 19:43
- i've just been testing in regex 101. good point though. I'll try your suggestion! – rimraf Commented Aug 2, 2017 at 19:44
- @KhauriMcClain this will give you a space before the text e.g " Some Text again" – Karl Taylor Commented Aug 2, 2017 at 19:45
3 Answers
Reset to default 3/[\s\S]- (.*)/g
- Should do it
[\s\S]
- For matching new lines
/g
- Continues matching