the text file content is:
In this script, we have the following variables:
1) $input_path to hold the path to the input file we want to parse
2) $output_file to hold the path to the file we want the results to be stored in
3) $regex to hold the regular expression pattern to be used when the strings are being matched.
The select-string cmdlet contains various parameters as follows:
1) “-Path” which takes as input the full path to the input file
2) “-Pattern” which takes as input the regular expression used in the matching process
3) “-AllMatches” which searches for more than one match (without this parameter it would stop after the first match is found) and is piped to “$.Matches” and then “$_.Value” which represent using the current values of all the matches.
$replace_file=@{}
$replace_text_file_path="EMS_checksystem_script\replace.txt"
$replace_file= gc $replace_text_file_path
$result=0
$valr=read-host "please enter the key word"
for($i=0;$i -lt$file_context.length;$i++)
{
$result=$replace_file[$i] -match $valr
if( $result -eq 1)
{
$replace_file[$i]
}
}
reslut:
key word: *pression
Bad argument to operator '-match': parsing "*pression" - Quantifier {x,y} following nothing..
At line:11 char:37
+ $result=$replace_file[$i] -match <<<< '*pression'
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : BadOperatorArgument
key word: pression*
3) $regex to hold the regular expression pattern to be used when the strings are being matched.
2) “-Pattern” which takes as input the regular expression used in the matching process
key word: press*on
NO result
how can use the press*on and *pression can sreach the result?