using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(?<!\d)(?<!_)(?<![a-zA-z])string(?!\d)(?!_)(?![a-zA-Z])";
string input = @"module mpi_hello_world
use mpi
implicit none
contains
subroutine hello_world(size, & ! testtest
& r_ank, &!
& myhostname &
& )
! this is a comment
! this also
integer, intent(in) :: size, rank23, rank_er,ranking, myrank, my2r_ank
character(len = *), intent(out) :: myhostname
integer :: stat
myhostname = ""(no host name)""
#ifdef __INTEL_COMPILER
call get_environment_variable(""COMPUTERNAME"", myhostname)
#else
stat = hostnm(myhostname)
#endif
write(*, *) ""Hello world FORTRAN rank:"", rank, "" size:"", size, &
& ""hostname:"", trim(myhostname)
end subroutine hello_world
end module mpi_hello_world
";
RegexOptions options = RegexOptions.Multiline;
foreach (Match m in Regex.Matches(input, pattern, options))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
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 C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx