Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8098545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T22:06:19+00:00 2026-06-05T22:06:19+00:00

I need to parse through a string and add single quotes around each Guid

  • 0

I need to parse through a string and add single quotes around each Guid value. I was thinking I could use a Regex to do this but I’m not exactly a Regex guru.

Is there a good Regex to use to identify a Guid?

My second question is once I’ve found a valid regex I’m assuming I would use Regex.Replace(String, String, MatchEvaluator) but I’m not quite sure of the syntax. Maybe something like:

return Regex.Replace(stringToFindMatch, GuidRegex, match =>
{
    return string.Format("'{0}'", match.Groups[0].ToString());
});

A string that I’m trying to parse may look like this:

“SELECT
passwordco0_.PASSWORD_CONFIG_ID as PASSWORD1_46_0_,
FROM
PASSWORD_CONFIG passwordco0_
WHERE
passwordco0_.PASSWORD_CONFIG_ID=baf04077-a3c0-454b-ac6f-9fec00b8e170;
@p0 = baf04077-a3c0-454b-ac6f-9fec00b8e170 [Type: Guid (0)]”

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T22:06:22+00:00Added an answer on June 5, 2026 at 10:06 pm

    This one is quite simple and does not require a delegate as you say.

    resultString = Regex.Replace(subjectString, 
         @"(?im)^[{(]?[0-9A-F]{8}[-]?(?:[0-9A-F]{4}[-]?){3}[0-9A-F]{12}[)}]?$", 
         "'$0'");
    

    This matches the following styles, which are all equivalent and acceptable formats for a GUID.

    ca761232ed4211cebacd00aa0057b223
    CA761232-ED42-11CE-BACD-00AA0057B223
    {CA761232-ED42-11CE-BACD-00AA0057B223}
    (CA761232-ED42-11CE-BACD-00AA0057B223)
    

    Update 1

    @NonStatic makes the point in the comments that the above regex will match false positives which have a wrong closing delimiter.

    This can be avoided by regex conditionals which are broadly supported.

    Conditionals are supported by the JGsoft engine, Perl, PCRE, Python, and the .NET framework.
    Ruby supports them starting with version 2.0. Languages such as Delphi, PHP, and R that
    have regex features based on PCRE also support conditionals. (source http://www.regular-expressions.info/conditional.html)

    The regex that follows Will match

    {123}
    (123)
    123
    

    And will not match

    {123)
    (123}
    {123
    (123
    123}
    123)
    

    Regex:

    ^({)?(\()?\d+(?(1)})(?(2)\))$
    

    The solutions is simplified to match only numbers to show in a more clear way what is required if needed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to parse strings for single and double quotes, and if the string
I need to parse through a CMS generated HTML page and add list item
I need to parse through the array and find out a value at particular
through jsonparsing i parse all the string values again i need to display the
I need to parse through a file(built from a string) searching for occurences of
I need parse through a file and do some processing into it. The file
I've got an array of values that i need to parse through and extract
I retrieve mail using net/pop , but I also need to parse through the
Hi I need parse and deserialize pseudo JSON string. Input data: {aBubbleData[ 'jaja2581' ]={
I need to parse a duration string, of the form 98d 01h 23m 45s

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.