command foo.$cmd command: { mapreduce: "lorem ipsum", map: "lorem ipsum", reduce: "lorem ipsum", verbose: true, query: { $comment: "I WANT TO KEEP THIS STRING", _id.foo: { $in: [ "lorem", "ipsum", "dolor"]}}
string_regex, _ := regexp.Compile(`"[^"]*"[,| }]`)
scanner := bufio.NewScanner(file)
for scanner.Scan() {
message := strings.SplitN(scanner.Text(), "]", 2)[1]
fmt.Println("Strings removed: " + string_regex.ReplaceAllString(message, "XXXX"))
(?!\$comment: )"...
However, I understand that Go's stdlib regexp does not support negative lookaheads.
In the absence of having that in regexp, what would be the next best alternative in Go?
$in: [ "lorem ipsum", "lorem ipsum"]
quoted_string_regex, _ := regexp.Compile(`(\$comment: )?"[^"]*"[,| }]`)
./redact.go:56: cannot use redact_if_not_comment(message) (type string) as type func(string) string in argument to quoted_string_regex.ReplaceAllStringFunc
fmt.Println("Everything" + quoted_string_regex.ReplaceAllFunc(message, redact_if_not_comment(matched_string)))
However, I ended up getting a type error - I could have sworn I got the types right, but obviously I'm missing something here:
./redact.go:56: cannot use redact_if_not_comment(message) (type string) as type func(string) string in argument to quoted_string_regex.ReplaceAllStringFunc
--
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
quoted_string_regex, _ := regex.Compile(`(\$comment: )?"([^"]*)"[,| }]`)
"Hello I'm a comment",
"ac85fd2b01946ab0a85111aecdbad81ebf021c34",
query { name: "John", age: 15, message: "This is a message with a quotation " mark right in the middle" }
victorhooi@thadeus ~/c/g/s/g/r/r/c/rjson> echo '{ mapreduce: "lorem", map: "function() {emit({id:this._id.fooId}, {version:this._id.vid, transId:this._id.transactionId})}", reduce: "function(key, vals) { var ver = vals[0]; for(var idx=1; idx<vals.length;idx++) { if (ver < vals[idx]) { ver = vals[idx]; }} return ver; }", verbose: true, out: { inline: 1 }, query: { $comment: "loremipsumdolor:44...@243c13n1.foo.com:kg._342Instance_1_dev.cached.tree-12:1572", _id.transactionId: { $in: [ "lorem", "ipsum", "dolor", "sic" ] }, _id.fooId: { $in: [ "lorem", "ipsum" ] }, lorem.ipsum.dolor: { $elemMatch: { loremType: "LOREM_IPSUM", lorem.ipsumDate: { $gt: "2014-02-24" } } } }, sort: {} }' | go run main.go
rjson: decode: invalid character '$' looking for beginning of object key stringexit status 1
victorhooi@thadeus ~/c/g/s/g/r/r/c/rjson> echo '{ $query: { $comment: "GetMaxLorem:18...@hz452c38n1.foo.com:pool-12-thread-4:3468", _id.id: "lorem ipsum" }, $orderby: { _id.version: -1 } }' | go run main.go
rjson: decode: invalid character '$' looking for beginning of object key stringexit status 1
victorhooi@thadeus ~/c/g/s/g/r/r/c/rjson> echo '{ query: { comment: "GetMaxLorem:18...@hz452c38n1.foo.com:pool-12-thread-4:3468", _id.id: "lorem ipsum" }, orderby: { _id.version: -1 } }' | go run main.go
rjson: decode: invalid character '_' looking for beginning of object key stringexit status 1
victorhooi@thadeus ~/c/g/s/g/r/r/c/rjson> echo '{ query: { comment: "GetMaxLorem:18...@hz452c38n1.foo.com:pool-12-thread-4:3468", id.id: "lorem ipsum" }, orderby: { id.version: -1 } }' | go run main.go
rjson: decode: invalid character '.' after object keyexit status 1