diff --git a/README.md b/README.md index 173ba43..5a347c6 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ If you want to read your local `.env` file, so you can use these variables in yo With this function the data will be loaded from the file and set as local variables. After that you can read them with standard functions, or you can use the following functions. -[Here](https://regex101.com/r/SEDjKj/5) you can find the regex expression which is used to read the environment variables. +[Here](https://regex101.com/r/SEDjKj/6) you can find the regex expression which is used to read the environment variables. ```go err := dotenv.Import(".env") diff --git a/import.go b/import.go index cbc45ed..c67cfe9 100644 --- a/import.go +++ b/import.go @@ -18,7 +18,7 @@ type data struct { } // regex is to save the compiled expression. -var regex = regexp.MustCompile(`(?m)(?P\w+?)=["']?(?P.*?)(?:["']|\b)$`) +var regex = regexp.MustCompile(`(?m)^(?P\w+?)=["']?(?P.*)(?:["']|\b)$`) // Import is read the environment variable file and use regex to find // all sub matches. After that we initialize the environment variables to local.