Re: [go-nuts] Regex questions: flags & match from start of string

2016-09-16 Thread Ian Lance Taylor
On Fri, Sep 16, 2016 at 7:00 AM, Scott Frazer  wrote:
> I'm struggling a lot here... I want to be able to pass flags to my regexps
> (specifically the flag where dot matches any character).  The only mention
> of flags at all is here: https://golang.org/pkg/regexp/syntax/#Parse.
> Though this API is strange and confusing.  I'm not sure what exactly to do
> with a syntax.Regexp.  Seems I can turn it into a syntax.Prog, but I'm very
> unclear about what to do with that object.
>
> Also, is there a way to say "match this regex anchored to the beginning of
> the string" without pre-pending the '^' character to all of my regexp's?

Don't worry about the regexp/syntax package.  You shouldn't use it.
If we could hide it without breaking the Go 1 contract, we would.

Specify flags by putting "(?flags)" at the start of your regexp.

I don't know of a way to anchor a regexp other than using ^.

Ian

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


[go-nuts] Regex questions: flags & match from start of string

2016-09-16 Thread Scott Frazer
I'm struggling a lot here... I want to be able to pass flags to my regexps 
(specifically the flag where dot matches any character).  The only mention 
of flags at all is here: https://golang.org/pkg/regexp/syntax/#Parse. 
 Though this API is strange and confusing.  I'm not sure what exactly to do 
with a syntax.Regexp.  Seems I can turn it into a syntax.Prog, but I'm very 
unclear about what to do with that object.

Also, is there a way to say "match this regex anchored to the beginning of 
the string" without pre-pending the '^' character to all of my regexp's?

Thanks,
Scott

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.