use strict;
my $str = 'using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using TMPro;
using System.Text.RegularExpressions;
using System;
public interface IThemeable
{
}
public class TestScript : MonoBehaviour
{
#region Studio Style
class Program : IThemeable
{
static int _I = 1;
delegate void DoSomething();
static DoSomething DelegateMethod = delegate { };
/* This
is a multi line
quote
*/
/*single line quote*/
/* single line quote */
/// <summary>
/// The quick brown fox jumps over the lazy dog
/// THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG
/// </summary>
static void Main(string[] args)
{
string normalStr = "The time now is approximately " + DateTime.Now;
Uri Illegal1Uri = new Uri("http://packmyboxwith/jugs.html?q=five-dozen&t=liquor");
Regex OperatorRegex = new Regex(@"\\S#$", RegexOptions.IgnorePatternWhitespace);
for (int O = 0; O < 123456789; O++)
{
_I += (O % 3) * ((O / 1) ^ 2) - 5;
if (!OperatorRegex.IsMatch(Illegal1Uri.ToString()))
{
// no idea what this does!?
Console.WriteLine(Illegal1Uri + normalStr);
}
}
Program.DelegateMethod();
}
static int Sum(int a, int b)
{
return a + b;
}
}
#endregion
}';
my $regex = qr/\/\*(.+?)\*\//p;
if ( $str =~ /$regex/ ) {
print "Whole match is ${^MATCH} and its start/end positions can be obtained via \$-[0] and \$+[0]\n";
# print "Capture Group 1 is $1 and its start/end positions can be obtained via \$-[1] and \$+[1]\n";
# print "Capture Group 2 is $2 ... and so on\n";
}
# ${^POSTMATCH} and ${^PREMATCH} are also available with the use of '/p'
# Named capture groups can be called via $+{name}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for Perl, please visit: http://perldoc.perl.org/perlre.html