2

I am trying to trim a space in an XML tag, this is an example of what I have:

<xmlT ag>
content between tag
</xmlTa g>

to:

<xmlTag>
content between tag
</xmlTag>

This is the expression that I wrote for that:

Find: [<](\w)* (\w)*[>]|[<][/](\w)* (\w)*[>]
Replace: \1\2

but is not working as expected.
Is there any other workaround for this?

1
  • 1
    Replace <xmlT ag> with <xmlTag>? Commented Mar 11, 2013 at 15:57

2 Answers 2

2

If the tags only have one space in them and no attributes, this will work

find: <(/?)(\w*) (\w*)>

replace: <\1\2\3>

Sign up to request clarification or add additional context in comments.

Comments

2

Using a LookAhead we can repair any number of spaces in a tag:

Search for: \s+(?=[\s\w]*>)
Replace with nothing

Explained demo here: http://www.regex101.com/r/dY6zC2

Note: LookAhead is available in NotePad++ since version 6.0

5 Comments

There is no lookahead in notepad++
Notepad++ supports PCRE including look-aheads and look-behinds (since v6.0).
@btoueg actually just tested on Notepad++ 6.3.1 and it supports LookAhead and works flawlessly.
@MikeM thanks for clarifying, also Notepad++ 6.3 was available at the time the question was posted
Ok, sorry about that. It looks like I can't change my vote unless the answer is edited.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.