Regexp finding string enclosed by quotes - regex

I have a little problem with VS2010.
So I want to find a certain strings between quotes with a Regexpression but only if the line doesn't contain a single "tr" or "QObject::tr" example:
I want to display all this lines:
Hallotr("asa");
("hhajkshjkas");
( _"hhajkshjkas" );
But don't want to display this lines:
tr("hhajkshjkas");
QObject::tr("hhajkshjkas");
My Regexp looks like this:
[^t-r]"[a-zA-Z0-9<>=\\"" ]* and ^[^tr]*"[a-zA-Z0-9<>=\\"" ]*"
but it shows all lines even if there is a single tr on the beginning of the string. Or it shows only lines which don't contain tr.
Thanks for help guys.

So I got the solution this is my regexp. :
^~((.*QObject.+tr)|(:b*tr:b*\()).*:q

Related

Notepad++ RegEX how do I append a character based on start of the character and before a character?

I would like to append _OLD to the end of each strings that starts with SR_ but before the symbol ' or without it
For example my text is the following:
SR_Apple
When the 'SR_APPLE' rotten, we must discard it.
I would like the find and replace to do:
SR_Apple_OLD
When the 'SR_APPLE_OLD' rotten, we must discard it.
I have tried (SR_*)+$.*(?='\s) based on what i Learned but no luck so far. Please help. Thx in Adv
For simple cases you should be able to use
Find: (\bSR_[\w]+)
Replace: $1_OLD
(\bSR_.+?)('|$) and $1_OLD$2 could also work if the text after SR_ is more complex
The lookbehind you're using is only matching the string if it ends with a ' so it won't find the text not in quotes.
regex101 is a useful tool for debugging expressions

Find commas in pattern

I have file with rows like this:
"B4P(6-3,5)-VH(LF)(SN)",JST,2018+,34000,SMD
893D226X0016C8W,VISHAY,2018+,"30,000",SMD
BL-BUF1V4V-AT-L,FOXLINK,2018+,1890,CONN
"TLP721F(D4-GR,M,F)",NSC,2001+,114,AUCDIP-16
How can i find all commas inside quotes? For example, i need to find this:
"B4P(6-3 >>,<< 5)-VH(LF)(SN)",JST,2018+,34000,SMD
893D226X0016C8W,VISHAY,2018+,"30 >>,<< 000",SMD
BL-BUF1V4V-AT-L,FOXLINK,2018+,1890,CONN
"TLP721F(D4-GR >>,<< M >>,<< F)",NSC,2001+,114,AUCDIP-16
Now I can only find text in quotes, tell me how to select only commas from it, using one regular expression?
("(?:\[??[^\[]*?"))
Regex101 - online regex editor and debugger
Here is a simplistic solution that works with your example:
It match only quoted strings having one or more , inside.
grep '"[^,]*,[^"]*"'
Hope it works for you.
Explanation
"[^,]* match " and following non , chars
, match the first , char
[^"]*" match following non " till find the next"

Regex to find specific character between two other characters

I've been trying to find a way to find a single comma between inverted commas without much luck. Example: "text , text " - how do I isolate the "," between the inverted commas line by line in a flat file?
My attempt .["].[,].["].
Thanks in advance
this regex will work
(?<=truck).*(?=car)
finds e.g. "plane" in the string
truckplanecar
so for test,test the regex would be
(?<=test).*(?=test)
PS. can you please provide an more detailed example what you would like to do
Try using 2 group at the start and end of the string, the following regex should work:
(".*),(.*")
it does match the example you've shared:
"text , text "
Furthermore, using groups, you can isolate the string before the comma and afterwards, in case you'll be needed it.

Remove spaces in string under quotation in Notepad++ using RegEx

Suppose I have these strings:
'akshay ' ,
' ankur'
I want to remove trailing and leading spaces present under quotation mark like this:
'akshay',
'ankur'
How can I achieve this in Notepad++ using RegEX?
Use this to find: '(\s*)(.*?)(\s*)' and this to replace: '\2'.
Find this regexp: (^')\s+(\w+)\s*(')|(^')\s*(\w+)\s+(')
Replace with : \1\2\3\4\5\6
Like this:
All the RegExp given above solve my problem in a better way. I appreciate to all who helped me to solve this problem. Thank you everyone.
Here i am going to add a RegExp given below which can be used to count total number of spaces inside single quotation. It can be used to remove all spaces also.
Find--> \s(?!(?:[^']*'[^']*')*[^']*$) and ReplaceWith-->Nothing to do(leave blank) then click 'ReplaceAll'.

Remove more than one comma in between quotes in CSV file using Regex

all! Have CSV files coming in with with text inside double quotes that contain one or more commas and I am wondering if there is a regex form for Notepad++ that would remove any number of commas inside a CSV file.
For example I need to go from the this:
text,text1,"interesting, text,"
To this:
text,text1,"interesting text"
There can be 1,2 or more commas inside the quotes.
Anyone know a of a way to make this happen using regex form in Notepad++?
Thanks in advance!
use this pattern
,(?!(([^"]*"){2})*[^"]*$)
and replace with nothing
it is looking for a comma , that does not see an optional even number of double quotes " to the end of the string