| 
									
										
										
										
											2010-11-22 23:47:07 +08:00
										 |  |  | function(escape_string_as_regex _str_out _str_in)
 | 
					
						
							| 
									
										
										
										
											2019-11-01 00:36:37 +08:00
										 |  |  |   string(REGEX REPLACE "\\\\" "\\\\\\\\" FILETEST2 "${_str_in}")
 | 
					
						
							|  |  |  |   string(REGEX REPLACE "([.$+*?|-])" "\\\\\\1" FILETEST2 "${FILETEST2}")
 | 
					
						
							|  |  |  |   string(REGEX REPLACE "\\^" "\\\\^" FILETEST2 "${FILETEST2}")
 | 
					
						
							|  |  |  |   string(REGEX REPLACE "\\(" "\\\\(" FILETEST2 "${FILETEST2}")
 | 
					
						
							|  |  |  |   string(REGEX REPLACE "\\)" "\\\\)" FILETEST2 "${FILETEST2}")
 | 
					
						
							|  |  |  |   string(REGEX REPLACE "\\[" "\\\\[" FILETEST2 "${FILETEST2}")
 | 
					
						
							|  |  |  |   string(REGEX REPLACE "\\]" "\\\\]" FILETEST2 "${FILETEST2}")
 | 
					
						
							|  |  |  |   set(${_str_out} "${FILETEST2}" PARENT_SCOPE)
 | 
					
						
							| 
									
										
										
										
											2010-11-22 23:47:07 +08:00
										 |  |  | endfunction()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function(test_escape_string_as_regex)
 | 
					
						
							| 
									
										
										
										
											2019-11-01 00:36:37 +08:00
										 |  |  |   set(test1 "\\.^$-+*()[]?|")
 | 
					
						
							| 
									
										
										
										
											2010-11-22 23:47:07 +08:00
										 |  |  |   escape_string_as_regex(test2 "${test1}")
 | 
					
						
							| 
									
										
										
										
											2019-11-01 00:36:37 +08:00
										 |  |  |   set(testRef "\\\\\\.\\^\\$\\-\\+\\*\\(\\)\\[\\]\\?\\|")
 | 
					
						
							| 
									
										
										
										
											2010-11-22 23:47:07 +08:00
										 |  |  |   if(NOT test2 STREQUAL testRef)
 | 
					
						
							|  |  |  | 	message("Error in the escape_string_for_regex function : \n   ${test1} was escaped as ${test2}, should be ${testRef}")
 | 
					
						
							| 
									
										
										
										
											2019-11-01 00:36:27 +08:00
										 |  |  |   endif()
 | 
					
						
							| 
									
										
										
										
											2010-11-22 23:47:07 +08:00
										 |  |  | endfunction()
 |