Search code examples
regextextwrangler

RegEx: Select space


Given the following string:

<Node type="java script">dataSetRow["Invoice Number"]</Node>
<Node type="java script">dataSetRow["Invoice Number 2"]</Node>

How would remove the space in between the brackets using regex in a text editor? For example, dataSetRow["Invoice Number"] would be come dataSetRow["InvoiceNumber"]. So far, the best I can do is match all the text between the brackets.

(?<=dataSetRow\[)(.*)(?=\])

However, I can't seem to match just the spaces so that I can remove them. Any help would be greatly appreciated.

Thanks


Solution

  • Here is a step-by-step instruction:

    1. Open Find and Replace dialog
    2. Check Use Grep
    3. In Search For, type (\[[^\]]*?)\s+
    4. In Replace With, type \1
    5. Click Replace All several times until no further replacements are performed (i.e. no matches are found).