0

I have spent days trying to work this out. Managed to get text to be captured but I need only one of the lines. I have tried various ways but always get all matches returned to me.

This line of text appears 3 times

<![LOG[Property SerialNumber is now = serial]LOG]!> 

using the Regex

 (?<=Property\sSerialNumber\sis\snow\s\=\s)[^<]+(?=]LOG]!>)

I get three matches of the word serial. I only need 1.

Where am i going wrong?

2
  • 4
    what text did you tried it on? can you give a sample text? Commented Jun 10, 2012 at 23:16
  • Some more context would be helpful. Why do you only want to match one of them? Are you checking for the presence of a string? Is your line of text repeated 3 times on separate lines or is it all together on one line? Commented Jun 12, 2012 at 1:24

1 Answer 1

1

If that exact line appears three times, then [Regex]::Matches will return all three of them, of course.

You can use [Regex]::Match if you're only interested in the first.

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

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.