1

I want to parse string:

????log L 07/31/2012 - 14:32:50: "Username1<4><STEAM_ID_PENDING><CT>" killed "Username2<2><STEAM_ID_PENDING><TERRORIST>" with "m4a1"

I must get values:

  1. Username1
  2. Username2
  3. m4a1

I have regex pattern

Regex reg = new Regex("[^\"]+\"([^<]+)<[^\"]+\" killed \"([A-Za-z0-9]+)[^\"]+\" with \"([A-Za-z0-9]+)\"");

This works perfectly if second username does not contains _ this or this - If first contains regex getting value.

Please help me to modify my pattern

Thanks

2 Answers 2

1

Replace it with this:

Regex reg = new Regex("[^\"]+\"([^<]+)<[^\"]+\" killed \"([^<]+)[^\"]+\" with \"([A-Za-z0-9]+)\"")

Group for finding name was:

([A-Za-z0-9]+)

I replaced it with:

([^<]+)

which is a pattern used to find first username.

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

Comments

0

Try this

(?<Username1>"Username1(?<data>[^"]*)")\s+killed\s+(?<Username1>"Username2(?<data>[^"]*)")\s+with\s+(?<m4a1>"m4a1(?<data>[^"]*)")

Named groups will return their respective values.

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.