140 likes | 298 Views
Regular Expression. Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology hoai@cse.hcmut.edu.vn. Text pattern. Used for text-processing utilities Text-pattern = normal characters + metacharacters = regular expression
E N D
Regular Expression Dr. Tran, Van Hoai Faculty of Computer Science and Engineering HCMC Uni. of Technology hoai@cse.hcmut.edu.vn
Text pattern • Used for text-processing utilities • Text-pattern = normal characters + metacharacters = regular expression • Metacharaters in regular expressions are different from those in file name expansion
Example (1) • grep [A-Z]* script*.sh • means grep a.txt abc script1.sh script2.sh • grep "[a-z]*" script*.sh • means to find the pattern "[a-z]*" in "script*.sh" • Good and safe solutions are "" and ''
Metacharacter sets • Depends on usage context • searching • replacing • Also depends on programs • Different engines • Perl • PHP • .NET regular expression library • Java JDK
Applications <TAG\b[^>]*>\(.*?\)</TAG> [A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}
text processing utilities is NEXT