Reputation: 34627
This is the list:
Work
Work
Fire
Global
And I want to extract the string WWFG
from it. [(?).*\n]
just give me Global
. What should I rather be using?
For context, I'm using Rainmeter's webparser plugin.
Upvotes: 2
Views: 1885
Reputation: 34627
(?siU)(?(?=.)(.))(?(?=.*\n).*\n(.))(?(?=.*\n).*\n(.))(?(?=.*\n).*\n(.))
Answered by @moshi here. And it works perfectly with Rainmeter.
Upvotes: 1
Reputation: 23727
Try this: (?simU)^(.)
RainRegExp seems to lack the replacement feature, so it is impossible to get all the captures concatenated into one string.
Upvotes: 2
Reputation: 2852
This will capture the first character from each line
([a-z])[^\n]+\n*
the replace with \1
or $1
Depending on what is in the text you might need to change [a-z]
to something more all-encompassing
Upvotes: 0
Reputation: 30736
I have no idea what language you're using, but here's some Python!
>>> import re
>>> ''.join(re.findall("(.).*", "Work\nWork\nFire\nGlobal"))
'WWFG'
Upvotes: 0
Reputation: 30273
The easiest way depends on what language you're using, but you want to replace
(.).*\n
with
$1
Upvotes: 1
Reputation: 2621
You need to use the multiline flag with an anchor
. I would use: /^(.)/gm
(syntax differs from language to language)
See example here: http://regex101.com/r/uC1gV5
Upvotes: 1