Hi, so I am using regex to go through a self defined config file.
The config file usually looks like this:
name=Some_name
proj=path/to/proj1
proj=path/to/proj2
then I identify "Some_name" using and the project paths using:
content = file.read()
given_name = re.search(r"(?i:name)\s*=\s*([^\n\s]*)", content).group(1)
project_paths = re.findall(r"(?i:proj)\s*=\s*([^\n\s]*)", content)
and this works great if a name is given. The problem occurs if someone forgets to enter a name, i.e. the file looks like:
name=
proj=path/to/proj1
proj=path/to/proj2
then the variable given_name becomes 'proj=path/to/proj1' instead of an empty string. I'm unsure why the regex expression skips the \n after name=, since no \n should be allowed between the = and the section I'm matching towards.
Or is there a better way to check if someone entered a name in the config file?