In my project, I have a situation in that some specific variables are assigned to numbers, but due to requirements, I have to change the numbers to a string.
For example, my original variable is like
question: 123
And I want to change it to
question: '123'
However, the var name is always the same what changes is the number so the match should be like
where question: check if the number has '' if not add around the number the ''
I was wishing for a regular expression for it as I have so many variables to change that manually is not easy, but I'm not good with RegEx
I'm also open to different suggestions if any no need mandatory a RegEx if there is a better solution to my issue
CodePudding user response:
You can do this as following:
- Press Ctrl H on Windows and Linux, or ⌥⌘F on Mac to enable the search and replace tool.
- Press the
.*button to enable regex - In the search field you can type the regex :
question: ([0-9] ) - In the replace field you can type :
question: '$1' - And replace all
Each occurence of question: <ANY NUMBER> will be replaced by question: '<ANY NUMBER>'
