This commit is contained in:
2022-02-28 16:40:21 +01:00
parent 4026aaef59
commit cded7691b2
32 changed files with 340 additions and 2 deletions

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -0,0 +1,81 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
namespace RegularExpressions {
internal class Program {
static void Main(string[] args) {
/*Hivatalos dokumentáció a Regexről
*https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expression-language-quick-reference
*https://docs.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions
*https://docs.microsoft.com/en-us/dotnet/api/system.text.regularexpressions.regex?view=net-6.0
*/
Regex regex = new Regex("^[1-9][0-9]*");
//a ^ karakter mondja meg hogy a strng elejétől kezdje
//a keretes zárójelen belül egy karakter sorozatot adunk meg, ezek között keresi a találatot (ennek a tagadása [^1-9])
//az első karakter sorozatot az első karakterrel vizsgálja a stringből
//a következö karaktersorozat pedig az utánna lévő karaktereket vizsgája
//a * nulla vagy több előfordulást jelent ebben az esetben a második karaktersorozatot nézi az első utáni összes karakterre
//a $ jel jelöli a string végét
string s1 = "012345";
string s2 = "112345";
string s3 = "2";
Console.WriteLine("{0} {1}",s1,(regex.IsMatch(s1) ? "természetes szám" : "nem természetes szám"));
Console.WriteLine("{0} {1}",s2,(regex.IsMatch(s2) ? "természetes szám" : "nem természetes szám"));
Console.WriteLine("{0} {1}",s3,(regex.IsMatch(s3) ? "természetes szám" : "nem természetes szám"));
////////////////////////////////////////////////////////////////////////////////////////////////////
string s = @"^(\+)[1-9][0-9]{1,2}\s[1-9][0-9]{1,2}\s(\d{3}(-)){2}\d{3}$";
Regex pattern = new Regex(s);
//a @ azt jelöli hogy a string tartalmaz speciális karaktereket
//a + jel elé egy \ kell írni mivel speciális karakter és a Regex is használja
//a {1,2} az jelöli hogy a plusz jel után minimun egy de max két karakter állhat (az előtte lévő karaktersorozatra vonatkozik)
//a \s egy szóközt jelöl
//a \d számokat jelöl ez esetben (\d{3}) azt jelenti hogy 3 db szám jön egymás után pl: 123
//ez után következzen két db kötőjel és ez kétszer fordul elő
//majd a végén megismételjük a hármas számsorozatot csak a kötőjel nélkül
string ss1 = "+36 30 661-345-612";
string ss2 = "+3630 661-567-233";
string ss3 = "+56 30 667-876-987-456";
Console.WriteLine(pattern.IsMatch(ss1)); // true
Console.WriteLine(pattern.IsMatch(ss2)); // false
Console.WriteLine(pattern.IsMatch(ss3)); // false
///////////////////////////////////////////////////////////////////////////////////////////
//További felhasználási módok
//Egy string részének az átírása
string pattern2 = "(Mr\\.? |Mrs\\.? |Miss |Ms\\.? )";
string[] names = { "Mr. Henry Hunt", "Ms. Sara Samuels",
"Abraham Adams", "Ms. Nicole Norris" };
foreach (string name in names)
Console.WriteLine(Regex.Replace(name, pattern2, String.Empty));
// Henry Hunt
// Sara Samuels
// Abraham Adams
// Nicole Norris
//Duplikáció keresés
string pattern3 = @"\b(\w+?)\s\1\b";
string input = "This this is a nice day. What about this? This tastes good. I saw a a dog.";
foreach (Match match in Regex.Matches(input, pattern3, RegexOptions.IgnoreCase))
Console.WriteLine("{0} (duplicates '{1}') at position {2}",
match.Value, match.Groups[1].Value, match.Index);
Console.ReadKey();
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RegularExpressions")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RegularExpressions")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("b8063178-720e-430c-b364-dc3f1dfce42c")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{B8063178-720E-430C-B364-DC3F1DFCE42C}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RegularExpressions</RootNamespace>
<AssemblyName>RegularExpressions</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Binary file not shown.

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]

View File

@@ -0,0 +1 @@
7f4b213b428f4c013f19137338418ee1f5525793

View File

@@ -0,0 +1,8 @@
C:\dev\c#\RegularExpressions\bin\Debug\RegularExpressions.exe.config
C:\dev\c#\RegularExpressions\bin\Debug\RegularExpressions.exe
C:\dev\c#\RegularExpressions\bin\Debug\RegularExpressions.pdb
C:\dev\c#\RegularExpressions\obj\Debug\RegularExpressions.csproj.AssemblyReference.cache
C:\dev\c#\RegularExpressions\obj\Debug\RegularExpressions.csproj.SuggestedBindingRedirects.cache
C:\dev\c#\RegularExpressions\obj\Debug\RegularExpressions.csproj.CoreCompileInputs.cache
C:\dev\c#\RegularExpressions\obj\Debug\RegularExpressions.exe
C:\dev\c#\RegularExpressions\obj\Debug\RegularExpressions.pdb

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace RekurzivHatvany {
class Program {
public static double Hatvany(double x, double y) {
if (y == 0) return 1.0;
else return x * Hatvany(x, y - 1);
}
static void Main(string[] args) {
Console.WriteLine(Hatvany(2, 10));
Console.ReadKey();
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("RekurzivHatvany")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RekurzivHatvany")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("da385dd5-70ce-4750-bdf8-03915d70f5b9")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{DA385DD5-70CE-4750-BDF8-03915D70F5B9}</ProjectGuid>
<OutputType>Exe</OutputType>
<RootNamespace>RekurzivHatvany</RootNamespace>
<AssemblyName>RekurzivHatvany</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

Binary file not shown.

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

Binary file not shown.

View File

@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]

View File

@@ -0,0 +1 @@
7f4b213b428f4c013f19137338418ee1f5525793

View File

@@ -0,0 +1,7 @@
C:\dev\c#\c-sharp\RekurzivHatvany\bin\Debug\RekurzivHatvany.exe.config
C:\dev\c#\c-sharp\RekurzivHatvany\bin\Debug\RekurzivHatvany.exe
C:\dev\c#\c-sharp\RekurzivHatvany\bin\Debug\RekurzivHatvany.pdb
C:\dev\c#\c-sharp\RekurzivHatvany\obj\Debug\RekurzivHatvany.csproj.AssemblyReference.cache
C:\dev\c#\c-sharp\RekurzivHatvany\obj\Debug\RekurzivHatvany.csproj.CoreCompileInputs.cache
C:\dev\c#\c-sharp\RekurzivHatvany\obj\Debug\RekurzivHatvany.exe
C:\dev\c#\c-sharp\RekurzivHatvany\obj\Debug\RekurzivHatvany.pdb

Binary file not shown.

Binary file not shown.

View File

@@ -1,7 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 12.00 Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17 # Visual Studio Version 16
VisualStudioVersion = 17.0.32126.317 VisualStudioVersion = 16.0.32106.194
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "c-sharp", "c-sharp\c-sharp.csproj", "{A6876A09-53D2-47AF-A648-81BAD791D19D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "c-sharp", "c-sharp\c-sharp.csproj", "{A6876A09-53D2-47AF-A648-81BAD791D19D}"
EndProject EndProject
@@ -17,7 +17,11 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BuborekRendezes", "BuborekR
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RekurzivFaktorialis", "RekurzivFaktorialis\RekurzivFaktorialis.csproj", "{F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RekurzivFaktorialis", "RekurzivFaktorialis\RekurzivFaktorialis.csproj", "{F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}"
EndProject EndProject
<<<<<<< HEAD
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegularExpressions", "RegularExpressions\RegularExpressions.csproj", "{B8063178-720E-430C-B364-DC3F1DFCE42C}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RegularExpressions", "RegularExpressions\RegularExpressions.csproj", "{B8063178-720E-430C-B364-DC3F1DFCE42C}"
=======
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RekurzivHatvany", "RekurzivHatvany\RekurzivHatvany.csproj", "{DA385DD5-70CE-4750-BDF8-03915D70F5B9}"
>>>>>>> c1046619c649e6be76c3e8746f0c75af47881513
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -53,10 +57,17 @@ Global
{F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}.Debug|Any CPU.Build.0 = Debug|Any CPU {F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}.Release|Any CPU.ActiveCfg = Release|Any CPU {F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}.Release|Any CPU.Build.0 = Release|Any CPU {F7BEEB1C-EB73-42E8-A148-3DB8C96B8D56}.Release|Any CPU.Build.0 = Release|Any CPU
<<<<<<< HEAD
{B8063178-720E-430C-B364-DC3F1DFCE42C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {B8063178-720E-430C-B364-DC3F1DFCE42C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B8063178-720E-430C-B364-DC3F1DFCE42C}.Debug|Any CPU.Build.0 = Debug|Any CPU {B8063178-720E-430C-B364-DC3F1DFCE42C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B8063178-720E-430C-B364-DC3F1DFCE42C}.Release|Any CPU.ActiveCfg = Release|Any CPU {B8063178-720E-430C-B364-DC3F1DFCE42C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B8063178-720E-430C-B364-DC3F1DFCE42C}.Release|Any CPU.Build.0 = Release|Any CPU {B8063178-720E-430C-B364-DC3F1DFCE42C}.Release|Any CPU.Build.0 = Release|Any CPU
=======
{DA385DD5-70CE-4750-BDF8-03915D70F5B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{DA385DD5-70CE-4750-BDF8-03915D70F5B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DA385DD5-70CE-4750-BDF8-03915D70F5B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DA385DD5-70CE-4750-BDF8-03915D70F5B9}.Release|Any CPU.Build.0 = Release|Any CPU
>>>>>>> c1046619c649e6be76c3e8746f0c75af47881513
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE