quote:
Originally posted by robert_dll
And how can I read something specific? For example, if I want to read the text next to "hi" in a file which content is "hi robert".
That totally depends on what is static in "hi robert".
- If you want to read the first word of a file, you can use a regular expression on the file's content:
js code:
var sContent = "hi robert";
var sResult = sContent.match(/^\b(\w+)\b/)[1];
// Result now equals "hi" as this is the first word
- If you know that "robert" is always the second word in the file and need to know what's in front of it:
js code:
var sContent = "hi robert";
var sResult = sContent.match(/^(.+)\srobert/)[1];
// Result now equals "hi" as this comes before "robert"
- ...