Dilip T Monson
Dilip T Monson

Reputation: 85

Unable to incorporate Regex expression for parsing backslash(\)

I am trying to create a regex expression to parse till \. Can you tell me how to create a regex expression.

The code i had created was

/[^\]*/

Upvotes: 0

Views: 48

Answers (2)

Marcos Casagrande
Marcos Casagrande

Reputation: 40404

If you want to get everything until a slash, just use:

/(.*?)\\/
  • (.*?) Capture group, containing the text until slash (not included)
  • .* Match everything 0 or more times.
  • ? make the quantifier (*) lazy, so it matches only until the first slash if there are more than one.

Check this: http://regexr.com/3cnld

Upvotes: 1

Ross A
Ross A

Reputation: 84

I find regex101.com really useful for testing regex.

I think you just need an extra backslash...

/[^\\]*/

Upvotes: 1

Related Questions