Tech Off Thread

4 posts

visual studio replace regexp help

Back to Forum: Tech Off
  • caroço

    hi,

    i'm not very good with regular expressions and i was wondering if somebody could help me building one to use in vs.net search and replace to change all ocurrences of

    localizedStrings.item(*)

    to

    localizedStrings[*]

    thanks

  • sloppycode

    So localizedStrings.item(<any match>) to localizedStrings[<any match>]

    is

    search: localizedStrings\.item\((.*)\)
    replace: localizedStrings\[\1\]

    should do the trick

  • Sven Groot

    sloppycode wrote:
    So localizedStrings.item(<any match>) to localizedStrings[<any match>]

    is

    search: localizedStrings\.item\((.*)\)
    replace: localizedStrings\[\1\]

    should do the trick

    Almost right. VS doesn't use entirely the same syntax as the .Net Framework regex class (for reasons no one knows) so you need to use {} to capture in the find expression instead of ().

  • caroço

    yeah youre right adding {} does the trick

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.