Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot define a raw string literal ending in double-quote #73677

Closed
weitzhandler opened this issue May 23, 2024 · 1 comment
Closed

Cannot define a raw string literal ending in double-quote #73677

weitzhandler opened this issue May 23, 2024 · 1 comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Comments

@weitzhandler
Copy link
Contributor

weitzhandler commented May 23, 2024

Version Used:
12

Steps to Reproduce:

Try to create a raw string literal of the following regex pattern ending in " or \":

Diagnostic Id:

Expected Behavior:
Should try to match the number of quotes both beginning to end (and perhaps vice versa), searching from end of string as well. This way, when the literal terminates in 3 dbl-quotes, even preceeded by another one will still compile.

Actual Behavior:
Doesn't compile.

@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels May 23, 2024
@CyrusNajmabadi
Copy link
Member

This is by design. Single line raw-strings cannot start or end with a ". You need to use a multi-line literal for that.

You need to write it like so: https://sharplab.io/#v2:EYLgtghglgdgNAFxFANgHwAICYCMBYAKAEgSTCMBmAAmxpwHZCBvQo7LVl4ogeh6oAqAJwCesAOZUEAeyoBjIQFMICRVIAWUAM5UASovGKAHlQAOK1UJhUA7lATqqEKkIg26ABiop7i1ylZefnUEBFMtED4lQyMhADo5aTAeAA4PaQQoQMC+KgBVLQkNJTUARwBXDMUtQIA3CCFixUUARUrVHQBeKgAiPsIqQaHhwYAdTtGegAoAbQgAWgAvAF0AagBKSYGRnb6egG4ybiI6hqoAM2lyoTaqrt697Z3h8cnZhZWNrYJnkb2D1gAX0IgKAA==

using System;
					
public class Program
{
	public static void Main()
	{
		// Trying to create this Regex pattern with a raw string literal
		// https://regexr.com/80oti
		
		// Using three quotes
		var threeQuotes = """
            \=\"([a-z]+)\"
            """;		
			
		var fourQuotes = """"
            \=\"([a-z]+)\"
            """";
	}
}

@CyrusNajmabadi CyrusNajmabadi closed this as not planned Won't fix, can't repro, duplicate, stale May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

No branches or pull requests

2 participants