How do I search for two strings on the same line in Eclipse? - eclipse

Mainly I want to search for all lines that contain XXX and YYY on the same line in Eclipse.
What would be the correct search expression for that?

This regex should comply with your request:
(XXX.*YYY|YYY.*XXX)
Used under File Search, checking Regular expression.

Use XXX*YYY in file search option.
This will mean that any characters can come in between XXX and YYY.

Related

Replace words but only after a colon

I have been researching this for quite some time but cannot seem to find an answer. Perhaps someone here can help.
I am trying to use sed to replace words in yml / yaml files. Since some of the words are included in the names I want to only replace words that appear after the colon (':').
For example. If the .yml file includes:
en:
label_some_tracker: A tracker
label_all_tracker: All trackers
label_attachment_type_trackers: Select trackers.
tracker_plural: trackers
and I want to replace all occurrences of tracker with issue in all values. The pattern:
s/tracker/issue/
also changes the names of the fields, which breaks my code.
I can reduce the size of the problem somewhat by including terms for all possible variants of a word. For example:
s/trackers/issues/
s/tracker/issue/
but that doesn't deal with all situations.
I have tried inserting a space before the search term:
s/ tracker/ issue/
but that matches names where the search term is at the beginning of the line.
If I search for whole words then it still seems to pick up the names because ':' and '_' are 'non word' characters.
If I try to put spaces at the beginning and end of the search term but then it misses words that are at the end of a line or words patterns with punctuation marks before the training space.
The only sure way seems to be to only replace words after a colon (':') but I cannot seem to figure out how to do that with sed.
Does anyone here know how?
With GNU sed:
sed -E 's/(:.*)tracker/\1issue/g' file
Output:
en:
label_some_tracker: A issue
label_all_tracker: All issues
label_attachment_type_trackers: Select issues.
tracker_plural: issues
Replace second occurance:
sed 's/tracker/issue/2' file

Find the good regex in eclipse

I would like to know if it's possible to filter code line from a search with eclipse.
Example: I have to extract all part of code between "" excluding all line starting with 'logger' and also all comment starting with //. I didn't find the exact RegEx to do that...
Can you help me please? Thanks in advance. Best regards.
You can use ^((?:[^\r\n"](?!logger)(?!//))++)("[^"]*+") for that:
the first group (\1) will contain the characters before the first "..." in a line,
the second group (\2) matches "...".
The restriction of this regular expression is that only the first "..." in a line will be matched.

Removing some paragraph marks in a word document

I copy text from PDF files into word 2010 documents using Abbyy conversion software. I find the result will contain many line breaks which are incorrect. Is there any way I can remove any such marks if they are not preceded by either "." or "?" or "!"
I write macros in excel but have no experience of word coding
You could do a search and replace depending if you can find some sort of rules wich you can apply. Mayeby a little screenshot?

How to search in resource files in Eclipse? (escaped chars)

How do you search in resource files (*.properties) in Eclipse for string containing non-ASCII characters?
EDIT: Currently I use * in place of those special chars, but I'd prefer Eclipse to handle this for me: so it would either search for '\u00E1' in raw files when I enter 'á', or it might translate the files first and then just search for 'á'.
My apologize for not being specific enough when asking.
In Eclipse, you can use Search -> File Search . In the Search dialog, check the Regular expression option. Then enter this pattern in the Containing text: field to find non-ASCII characters:
[\u007f-\uffff]
(the square brackets are part of the pattern). Enter the File name patterns
*.properties
and then select which resources to search (selected resource, workspace, working set, etc.) and click OK
See also the Pattern javadoc for how to express such regular expressions.
Personally, I search them from the command line using grep, but you can search them in Eclipse by using a question mark in a non-regular-expression search, which should match any character. You can also use a period in a regular expression search.
The search dialog allows you to search for strings in *.resources files in the workspace.
Go to Search -> File. Enable the Regular Expressions checkbox - this also content assist to choose the regular expression according to your needs. In the file name patterns, give *.properties and then, Go :)

Option in diff to show differences in lines that include a certain word

Is there any way using diff to show differences only in lines that include an specific word?
You can specify the option '-I regexp' to ignore the lines which match the specified regular expression. If you inverse the regex, you can ignore all lines NOT containing the word you're looking for.
See the diff manpage for more info or here for a specific example.