We are not native Java/Javascript programmers but sometimes get help from these languages to satisfy some of our job.
We are working on some testing automation tool which supports XML-Javascript expression writing. There we have 'Verify' option to confirm if our required string is present in the input file or not. We usually use inputfile.indexOf('XYZ') expression to validate if XYZ string is present in the inputfile (this inputfile is just an array of characters from file, and is made readily available by tool to 'Verify' option. It contains some file data which we know, you can consider it as a random text file).
Now, our requirement is to check if 'abc' is available and if it is available then 'xyz' should be also made available. Ultimately, the number of times 'abc' occurs in inputfile, same number of times 'xyz' also should be available in inputfile. In all these scenarios, my expression should result TRUE otherwise should always FALSE.
Any suggestion on how to proceed for such expression in javascript ?
question from:
https://stackoverflow.com/questions/65951540/any-suggestion-on-javascript-expression-to-count-the-number-of-occurrences-of-a 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…