Detect Code Reference

Jan 3, 2016 at 7:40 AM
Hello,

I am trying to write a regular expression to match the following:
GetGlobalResourceObject("Strings", "the value")

I tried the bleow regex but it's not working:
GetGlobalResourceObject($File)\s*,\s*($Key)\

Please let me know what am I doing wrong here.

Thank you,
Coordinator
Jan 4, 2016 at 6:26 AM
Edited Jan 4, 2016 at 6:27 AM
You must use a valid regex that matches the source, not just looks similar:
GetGlobalResourceObject\("($File)"\s*,\s*"($Key)"\) 
Jan 5, 2016 at 7:14 AM
Thank you very much for the code you provided.

Actually, it's still not working as expected. All of the below usage are not detected by the regex GetGlobalResourceObject("($File)"\s*,\s*"($Key)")
  1. GetGlobalResourceObject("Strings", "Company Settings")
  2. (string) GetGlobalResourceObject("Strings", "Company Settings")
  3. <%# GetGlobalResourceObject("Strings", "Company Settings") %>
The only usage which is detected properly is for the regex:
<%\$\s+Resources:\s($File)\s,\s($Key)\s%>
<%$ Resources:Strings,Travel Period %>

Thank you,
Coordinator
Jan 5, 2016 at 7:19 AM
Seems you dropped some of the "\"
Jan 6, 2016 at 7:18 AM
Edited Jan 6, 2016 at 7:23 AM
I have it correct in the program, it's trimmed when I copied it and pasted in the editor.

Here is my configuration:
https://www.dropbox.com/s/shvxd968tgsltbr/Capture.PNG?dl=0

It's not capturing the usage as expected.

Thank you,
Coordinator
Jan 7, 2016 at 8:20 AM
Can you send me a sample?
Jan 7, 2016 at 9:00 AM
For example, the below usages are not captured from the .cs files:
GetGlobalResourceObject("Strings", "Company Settings")
(string) GetGlobalResourceObject("Strings", "Company Settings")


And this usage also is not captured from the .aspx or ascx pages:
<%# GetGlobalResourceObject("Strings", "Company Settings") %>

"Company Settings" is the value and "Strings" is the file.

Thank you,
Coordinator
Jan 9, 2016 at 10:28 AM
Edited Jan 9, 2016 at 10:29 AM
So you have a "Strings.resx" resource in your project, with an entry "Company Settings" = "<localized string>"?
Jan 9, 2016 at 1:37 PM
Edited Jan 9, 2016 at 1:37 PM
Yes. Please check the below image:

screenshot

Thank you,
Coordinator
Jan 9, 2016 at 2:57 PM
Jan 10, 2016 at 1:50 PM
In your screenshot, your Strings.resx files is placed directly under the root and not inside the App_GlobalResources folder. I tried the same in my project and it worked.

If the Strings.resx is inside the App_GlobalResources folder, then it will not work as expected.

For me it's OK now as long as it gives me the correct results.

Thank you very much for your time and support.

All the best,
Coordinator
Jan 13, 2016 at 3:52 PM
Works also if inside a sub folder: http://1drv.ms/22Zvgzz