Skip to content

Commit c3f1985

Browse files
committed
Simplify regex used in is_valid_smt_identifier
There are 2 simplifications here. 1) A swap to a normal string literal, rather that a raw string literal, as there is only a single character which needs escaping. 2) A change to remove the `^` and `$` for matching the start and end of the string. These were redundant, because `std::regex_match` already requires the regex to match the full string rather than a partial sub-match. This simplification is already tested by the "smt_identifier_termt construction" test in the smt_terms unit tests.
1 parent 2ca390c commit c3f1985

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/solvers/smt2_incremental/smt_terms.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static bool is_valid_smt_identifier(irep_idt identifier)
5252
{
5353
// The below regex matches a complete string which does not contain the `|`
5454
// character. So it would match the string `foo bar`, but not `|foo bar|`.
55-
static const std::regex valid{R"(^[^\|]*$)"};
55+
static const std::regex valid{"[^\\|]*"};
5656
return std::regex_match(id2string(identifier), valid);
5757
}
5858

0 commit comments

Comments
 (0)