0

I need a regex matcher to find the pattern for a list consisting of a bunch of records

all of which end with a comma.

I want to, at the first occurrence of the comma insert beginning and end h1 tags.

I tried using (.*),

4
  • Can we see a sample input and output list? Commented Jan 27, 2013 at 22:50
  • Random Text In One Row, <- this is how every line looks. ends with a comma Commented Jan 27, 2013 at 22:51
  • Just tried in notepad++, your regex works, did you enable the regex search in the bottom-left corner of the search box? Commented Jan 27, 2013 at 22:52
  • can you provide exactly what regex you used? (.*), <- ? Commented Jan 27, 2013 at 22:54

3 Answers 3

1

This should capture everything on a line up until and including the comma:

[^,]*?,
Sign up to request clarification or add additional context in comments.

2 Comments

But hey what if I want to end the line after the first occurrence of the comma? Because there are more commas on the same line, and I dont want them to be altered
This will depend on the regex implementation that you are using. The regex here by itself will start the the beginning of a string and match everything up tp and including the first comma. So long as your regex function does not globally match all occurrences, this will ignore all other comma-delimited text on the line.
1

You can use this regex:

^([^,]*),

This will locate the string before the first comma in a line. There is also capturing group that captures the text before the first comma for reference in replacement.

Comments

1

Try using either (.*?), or ([^,]+),. The former is preferred, but Notepad++ may not support it.

1 Comment

But this only locates the comma... I need to locate the string before the comma.

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.