Reputation: 191
So, this looks really trivial but I was unable to solve it.
After a regex run in a file line like:
(In this example I'll be looking for /Name: it could be as well for Arch.Type etc...)
/Name: Plugin /Version: 1.0 /Arch: Windows 64 Windows 32 Linux Mac /Summary: asdasdas /Type: sdfsdf
I've got a string like:
Plugin /Version: 1.0 /Arch: Windows 64 Windows 32 Linux Mac /Summary: asdasdas /Type: sdfsdf
I need to remove everything from this string that it's after the first "/" (Thus leaving only "Plugin")
Upvotes: 0
Views: 3597
Reputation: 137567
You can remove everything from the first /
in a string onwards using this:
set myVar [regsub {/.*} $myVar ""]
# Old school Tcl 8.4 and before version (upgrade, man!)
regsub {/.*} $myVar "" myVar
It's better to not capture the stuff that you don't want in the first place though.
Upvotes: 1
Reputation: 501
Try this:
regexp {/Name: ([^/]+)} {/Name: Plugin /Version: 1.0 /Arch: Windows 64 Windows 32 Linux Mac /Summary: asdasdas /Type: sdfsdf} all match
puts $match
Parenthesized capturing expression that will match any character but slash, one or more times.
Upvotes: 2