In my project I need to extract some parameters from a settings file. Below is a section of the line that I am reading, the parameter I need to extract is the Program Prefix.
... ProgramPrefix="" ReceiveTimeout="80000" ...
I need to extract what is between the double quotes for ProgramPrefix. The problem is that in-between these quotes can be any alphanumeric character, symbol, space, or no character at all.
Below is my current solution for extracting any character before the second double-quote, the problem it doesn't work for the case of nothing being between the double quotes
EOPdefL = string.find(line,"ProgramPostfix=")
EOPdef = string.match(line,'([^"]+)',EOPdefL+16)
When there is nothing in-between the double quotes the output for EOPdef is:
EOPdef = ReceiveTimeout=
I would like EOPdef to just return an empty string if there are no characters.
EOPdef = ""
Aucun commentaire:
Enregistrer un commentaire