Correct Expression For 'Any Character Including Whitespace'
-
Hi all, I've been fighting with this for hours now, but don't get it to work. I want to strip out some information from an ini-file, which basically looks like this:
[CameraDefinition.1]
Title=Linke Seite
Guid={0ae3f864-da10-4e5a-977c-b9bba47d6f7a}
Description=Ansicht nach links
Origin=CenterIt's a standard Windows text file, the sections are separated with two new lines (\r\n\r\n). My regex currently looks like this: "\[CameraDefinition\.(?\d+)\][.|\s]*Guid=(?\{[0-9A-F\-]*\})" While the first (CamNumber) and the last part (Guid) return correct results as 'partial match', the critical part seems to be the underlined expression for "everything between the top and the Guid", which might be several lines. I'd be happy if someone of you helps me solve this... Thank you in advance! Regards Mick
-
Hi all, I've been fighting with this for hours now, but don't get it to work. I want to strip out some information from an ini-file, which basically looks like this:
[CameraDefinition.1]
Title=Linke Seite
Guid={0ae3f864-da10-4e5a-977c-b9bba47d6f7a}
Description=Ansicht nach links
Origin=CenterIt's a standard Windows text file, the sections are separated with two new lines (\r\n\r\n). My regex currently looks like this: "\[CameraDefinition\.(?\d+)\][.|\s]*Guid=(?\{[0-9A-F\-]*\})" While the first (CamNumber) and the last part (Guid) return correct results as 'partial match', the critical part seems to be the underlined expression for "everything between the top and the Guid", which might be several lines. I'd be happy if someone of you helps me solve this... Thank you in advance! Regards Mick
-
Probably easier just to read it line by line and look for the keyword you are interested in.
-
Hi all, I've been fighting with this for hours now, but don't get it to work. I want to strip out some information from an ini-file, which basically looks like this:
[CameraDefinition.1]
Title=Linke Seite
Guid={0ae3f864-da10-4e5a-977c-b9bba47d6f7a}
Description=Ansicht nach links
Origin=CenterIt's a standard Windows text file, the sections are separated with two new lines (\r\n\r\n). My regex currently looks like this: "\[CameraDefinition\.(?\d+)\][.|\s]*Guid=(?\{[0-9A-F\-]*\})" While the first (CamNumber) and the last part (Guid) return correct results as 'partial match', the critical part seems to be the underlined expression for "everything between the top and the Guid", which might be several lines. I'd be happy if someone of you helps me solve this... Thank you in advance! Regards Mick
The format of entries in an ini file is
Key=Value
. That is, get the position of the first=
sign, the substring on the left is the key, the substring on the right is the value. -
Hi Richard, thank you for your response. It's exactly what I did meanwhile... still I hope someone knows an answer, so that this seemingly simple task wouldn't annoy me again :-)
-
Hi all, I've been fighting with this for hours now, but don't get it to work. I want to strip out some information from an ini-file, which basically looks like this:
[CameraDefinition.1]
Title=Linke Seite
Guid={0ae3f864-da10-4e5a-977c-b9bba47d6f7a}
Description=Ansicht nach links
Origin=CenterIt's a standard Windows text file, the sections are separated with two new lines (\r\n\r\n). My regex currently looks like this: "\[CameraDefinition\.(?\d+)\][.|\s]*Guid=(?\{[0-9A-F\-]*\})" While the first (CamNumber) and the last part (Guid) return correct results as 'partial match', the critical part seems to be the underlined expression for "everything between the top and the Guid", which might be several lines. I'd be happy if someone of you helps me solve this... Thank you in advance! Regards Mick
Hello and thank you both! :thumbsup: In order to solve the regex issue, I successfully tried to read the first three lines of each block:
\[CameraDefinition\.(?\d+)\]\r\nTitle\=(?.*)\r\nGuid\=(?<Guid>\{[0-9A-Fa-f\-]*\})</pre>Considering the results, this works well, is fast and gives me the title as an additional field. In case I recognize any errors, I'll go back to reading line by line and also consider your hint regarding general ini-file structure.
Thank you again, and have a nice day! :)
EDIT: Changing the critical middle part to the following helped...
<pre>\[CameraDefinition\.(?<CamNumber>\d+)\]\r\n(.*\r\n)Guid\=(?<Guid>\{[0-9A-Fa-f\-]*\})\r\n{1,}</pre>This way I have the correct matches as well. But: Still no capture if there are more lines between the top line and the GUID definition.</x-turndown> -
Hello and thank you both! :thumbsup: In order to solve the regex issue, I successfully tried to read the first three lines of each block:
\[CameraDefinition\.(?\d+)\]\r\nTitle\=(?.*)\r\nGuid\=(?<Guid>\{[0-9A-Fa-f\-]*\})</pre>Considering the results, this works well, is fast and gives me the title as an additional field. In case I recognize any errors, I'll go back to reading line by line and also consider your hint regarding general ini-file structure.
Thank you again, and have a nice day! :)
EDIT: Changing the critical middle part to the following helped...
<pre>\[CameraDefinition\.(?<CamNumber>\d+)\]\r\n(.*\r\n)Guid\=(?<Guid>\{[0-9A-Fa-f\-]*\})\r\n{1,}</pre>This way I have the correct matches as well. But: Still no capture if there are more lines between the top line and the GUID definition.</x-turndown>