Selecting highlighted code

Hello all,

I’m new to the community and Komodo in general.

I’m having hard time figuring out how to select (and copy into the clipboard) some strings (from multiple lines), which are already highlighted as a result from using the Find function (with RegEx).
The Find function itself is giving me the results as entire lines, whereas I want just the specific strings.
Just to make it clear here is an example:

My code is:

<string name="signin_btn">text 1</string>
<string name="signin_empty_email">text 2</string>
<string name="signin_empty_password">Some other text</string>
<string name="signin_empty_pin">Lots more text</string>
<string name="signin_email_in_wrong_format">Other text, including %s placeholders.</string>

I need to copy to the clipboard just:

text 1
text 2
Some other text
Lots more text
Other text, including %s placeholders.

The RegEx I used to find the text I need is:
(?<=\">)(.*?)(?=\</)

Any ideas how to achieve that, as it seems my intelligence is betraying me?

Thanks!
Alex

Hee @Alex_Grant,

For me the simplest way to achieve this, would be to create a small userscript:

var currentView = require("ko/views").current(), // current view
	scimoz = currentView.scimoz, // scimoz
	input = scimoz.text, // buffer
	selText = scimoz.selText, // Selected text
	clipboard = require("sdk/clipboard"); 

// If text is selected use this
if (selText.length > 0) {
	input = selText;
}

// Execute regex on content
output = input.replace(/<[^>]+>([^<]+)<\/[^>]+>/gm, '$1');

// copy output to clipboard
clipboard.set(output);

I’m using a different kind of Regex, but the result is what you want.
Hope this helps you out.

2 Likes

Thank you Babobski!

Works great :grinning: