source: pacpussensors/trunk/Vislab/lib3dv/eigen/cmake/RegexUtils.cmake@ 137

Last change on this file since 137 was 136, checked in by ldecherf, 8 years ago

Doc

File size: 936 bytes
Line 
1function(escape_string_as_regex _str_out _str_in)
2 STRING(REGEX REPLACE "\\\\" "\\\\\\\\" FILETEST2 "${_str_in}")
3 STRING(REGEX REPLACE "([.$+*?|-])" "\\\\\\1" FILETEST2 "${FILETEST2}")
4 STRING(REGEX REPLACE "\\^" "\\\\^" FILETEST2 "${FILETEST2}")
5 STRING(REGEX REPLACE "\\(" "\\\\(" FILETEST2 "${FILETEST2}")
6 STRING(REGEX REPLACE "\\)" "\\\\)" FILETEST2 "${FILETEST2}")
7 STRING(REGEX REPLACE "\\[" "\\\\[" FILETEST2 "${FILETEST2}")
8 STRING(REGEX REPLACE "\\]" "\\\\]" FILETEST2 "${FILETEST2}")
9 SET(${_str_out} "${FILETEST2}" PARENT_SCOPE)
10endfunction()
11
12function(test_escape_string_as_regex)
13 SET(test1 "\\.^$-+*()[]?|")
14 escape_string_as_regex(test2 "${test1}")
15 SET(testRef "\\\\\\.\\^\\$\\-\\+\\*\\(\\)\\[\\]\\?\\|")
16 if(NOT test2 STREQUAL testRef)
17 message("Error in the escape_string_for_regex function : \n ${test1} was escaped as ${test2}, should be ${testRef}")
18 endif(NOT test2 STREQUAL testRef)
19endfunction()
Note: See TracBrowser for help on using the repository browser.