Fixed bug with parentheses in lookaround regex; fixed bug with reading last line of test string (if it doesn't end in a newline)
This commit is contained in:
10
main.go
10
main.go
@@ -156,7 +156,7 @@ func shuntingYard(re string) []postfixNode {
|
||||
*/
|
||||
c := re_postfix[i]
|
||||
if isNormalChar(c) {
|
||||
if *caseInsensitiveFlag {
|
||||
if caseInsensitiveFlag != nil && *caseInsensitiveFlag {
|
||||
outQueue = append(outQueue, newPostfixNode(allCases(c)...))
|
||||
} else {
|
||||
outQueue = append(outQueue, newPostfixNode(c))
|
||||
@@ -204,9 +204,6 @@ func shuntingYard(re string) []postfixNode {
|
||||
regex += string(re_postfix[i])
|
||||
i++
|
||||
}
|
||||
if regex[len(regex)-1] == ')' { // The closing paren would have also been added. Let's remove that.
|
||||
regex = regex[:len(regex)-1]
|
||||
}
|
||||
if len(regex) <= 1 { // Nothing in regex - panic
|
||||
panic("Invalid lookaround. (too short?)")
|
||||
}
|
||||
@@ -574,13 +571,16 @@ func main() {
|
||||
}
|
||||
// Assuming err != nil
|
||||
if err == io.EOF {
|
||||
if len(temp) > 0 {
|
||||
test_str += temp // Add the last line (if it is non-empty)
|
||||
}
|
||||
linesRead = true
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
test_runes = []rune(test_str)
|
||||
matchIndices := findAllMatches(startState, []rune(test_runes))
|
||||
matchIndices := findAllMatches(startState, test_runes)
|
||||
if *printMatchesFlag {
|
||||
for _, idx := range matchIndices {
|
||||
fmt.Printf("%s\n", idx.toString())
|
||||
|
Reference in New Issue
Block a user