0

i have a text file which contains lots of email addresses from my old address book. I need to get these out of it. every email addy is preceeded with

ip:

and ends with

\

for example

blablablaip:[email protected]\

the addresses are up to 25 characters in length(not sure if that makes a difference for the required regex im a noob) and sometimes there is a line break in the middle of an address, i.e an email address is split between the end of a line and the start of a new line.

Any of you regex wizards offer me any help please?

thanks in advance

3 Answers 3

1

You can try this regex :

/ip:(.{0,25}?)\/

It works like this :

/         <- The delimiter of your regex
    ip:       <- Matches the "ip:" part
    (             <- Open a capture group
        .         <- Matches any character 
        {0,25}    <- Last part repeated between 0 and 25 times
        ?         <- Ungreedy modifier, to capture less elements possible (in the 0, 25 limit)
    )         <- End of the capture group
    \         <- The "\" part
/         <- End of the regex

In C# you don't need delimiters in your regex so you can use this :

@"ip:(.{0,25}?)\\" //Don't forget to escape the \ 

Resources :

Sign up to request clarification or add additional context in comments.

Comments

0

regex you're looking for is

ip:(.*?)\\

Comments

0

You might want to strip the line-breaks, just for simplicity.

After that:

String regex = @"ip:(?'email'(.*)@(.*\.*))\\";

No length restrictions or character restrictions, but it will match the [email protected] part of a email and place it in the email group.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.