Regex help

I need to capture all lines that start C: and end in <br />

i am struggling to match the end <br />

i wish to do preg_match_all can any one help?

Can you give us an example of a string you want to match and not match?


cheers dude :slight_smile:

the line would look like

C: server port username password
C: 12000 admin admin

they are an example

Are you talking break tags or newlnes/carriage returns or all?

You surely want .*? instead…

id like it so that it would just literally match any line that looked like

C: 12000 admin admin

and it ignore after the last bit with the <br>

I found a solution i think now ill post the solution later for any one else looking for something similar

I think you’re getting confused between <br /> tags and newlines (

Something like ^C:.*?$ should do the trick.

I’m not familiar enough with PHP syntax to write something off the top of my head, but in Ruby it would be:

str = "
C: 12000 admin admin
Some other stuff
C: 12000 admin admin

p str.scan(/^C:.*?$/)
=> ["C: 12000 admin admin", "C: 12000 admin admin"]


many thanks i will give this a go :slight_smile:

thank you everyone for your help!