Pages

Friday, September 28, 2012

Regular expression for finding the special chars present in a given string

<?php
$str = "qdsdasdadsasd\";
$exp ="~@#$%^&*()_+=-[]'\|;  \"  :,./?";

if (preg_match("/[\~@#$%^&*()_+=-\[\]\'|;,.?\/\\\\\\\\]/", $str)) {
    echo "A match was found.";
} else {
    echo "A match was not found.";
}

?>

1 comment:

  1. [URL=http://chennaitraining.in/etl-testing-training-in-chennai/]ETL Testing Training In Chennai[/URL]
    [URL=http://chennaitraining.in/java-training-in-chennai/]Java Training In Chennai[/URL]
    [URL=http://chennaitraining.in/python-training-in-chennai/]Python Training In Chennai[/URL]
    [URL=http://chennaitraining.in/r-programming-training-in-chennai/]R Programming Training In Chennai[/URL]
    [URL=http://chennaitraining.in/salesforce-developer-training-in-chennai/]Salesforce Developer Training In Chennai[/URL]
    [URL=http://chennaitraining.in/sap-hana-training-in-chennai/]SAP HANA Training In Chennai[/URL]
    [a]SAP MM Training In Chennai[/URL]

    ReplyDelete