Inserting whitespace special characters

Having trouble installing <oXygen/>? Got a bug to report? Post it all here.
xinelo
Posts: 33
Joined: Wed Oct 04, 2006 6:25 pm

Inserting whitespace special characters

Post by xinelo » Mon Apr 19, 2010 3:05 pm

Hi,

In Oxygen I can search for whitespace (newlines, tabs, etc.) using regular expressions, but if I want to replace what I find with some of those special characters I can't use the regular expression and I have to use the character itself.

Imagine I want to replace a newline with a tab, I search for

Code: Select all

^(.+)\n(.+\n)
and replace it with

Code: Select all

$1\t$2
I won't work. I need to use (just in case the output is not identical to my input, between the two variables below there's a tab, not three spaces).

Code: Select all

$1	$2
Is there any way I can use the former? It's a bit annoying having to copy the tab somewhere and paste it in the search dialog (as it can't be typed there directly).

Thanks a lot!

Cheers, Manuel

adrian
Posts: 2699
Joined: Tue May 17, 2005 4:01 pm

Re: Inserting whitespace special characters

Post by adrian » Mon Apr 19, 2010 5:17 pm

Hello,

If you right click in either the find or the replace text areas from the Find/Replace dialog you will get a contextual menu which has as its last two actions: 'Insert newline' and 'Insert tab'

'Insert newline' also has a shortcut: Ctrl+Enter

Let me know if I misunderstood and that's not what you were looking for

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

xinelo
Posts: 33
Joined: Wed Oct 04, 2006 6:25 pm

Re: Inserting whitespace special characters

Post by xinelo » Tue Apr 20, 2010 2:42 am

Hi Adrian,

Thanks a lot for your reply!

I think you understood. While your answer is not what I was after, it does help me to perform my searches and replaces, as I don't need to copy-paste anymore.

However, it would still be handy to be able (to choose) to type the regex instead of entering the character itself, it would make expressions more compact, concise and clear. But I guess this way of doing it has to do with XML syntax perhaps...

Actually out of my ignorance I wonder why in the field field it's possible to use \n or \t but not in the replace field.

Cheers and thanks again, Manuel

adrian
Posts: 2699
Joined: Tue May 17, 2005 4:01 pm

Re: Inserting whitespace special characters

Post by adrian » Tue Apr 20, 2010 9:55 am

Hi,

The patterns in the replace field are a limitation of the Java regular expression engine. By default it only supports groups in the replace string.

But now that you mention it '\t' in the replace field should have worked.
\t, \n, \r, \uXXXX, \xXX, \0->\9 have all been specifically implemented since the release of Oxygen 10.3.

What version of Oxygen are you using?

Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com

xinelo
Posts: 33
Joined: Wed Oct 04, 2006 6:25 pm

Re: Inserting whitespace special characters

Post by xinelo » Tue Apr 20, 2010 10:59 am

Yep, my version is 10.0. That might be why.

If I use \t all I get is a t (an escaped t?).

I'll install the newest and see.

Thank you very much, Adrian, you have been very helpful!

Cheers, Manuel

Post Reply