블로그 이미지
Every unexpected event is a path to learning for you.

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
04-20 00:00

[링크] https://github.com/fatherscott/GoodTiger

 

GitHub - fatherscott/GoodTiger

Contribute to fatherscott/GoodTiger development by creating an account on GitHub.

github.com

 

반응형
Posted by blueasa
, |

[링크] https://codingcoding.tistory.com/584

 

Well512 알고리즘 예제, 난수 생성기, 랜덤 포레스트 (Random Forest)

Well512 알고리즘 예제, 난수 생성기, 랜덤 포레스트 (Random Forest) 주요 참조 사이트 : 표준 rand()함수보다 유용한 난수 생성기 알고리즘 – MT, WELL512 [링크] 소스 코드 - WindowsFormsApplication1.zip..

codingcoding.tistory.com

 

반응형
Posted by blueasa
, |

[링크] https://developstudy.tistory.com/74

 

C# 자주 쓰는 Collection 집계 함수

자주 쓰는 컬렉션 집계함수들을 모아서 간단하게 사용법을 정리해보았다. 아래에서 사용한 함수는 아래와 같다. 0. Foreach 1. FindAll(찾기) 2. Except(차집합) 3. ToDictionary(사전화) 4. Select(골라내기) 5...

developstudy.tistory.com

 

반응형
Posted by blueasa
, |

참고

[ http://blog.naver.com/PostView.nhn?blogId=teshe&logNo=140055084055&widgetTypeCall=true ]

 

화면에 \3000 이렇게 표시하고 싶었는데 

""\\"" 를 사용하면 역슬래시만 표시 된다. 

 

그래서 \를 표시하기 위해 찾아봤는데 아래의 NumberFormatInfo 클래스를 사용하면 된다. 

 

using System.Globalization;

 

double price = 3000;

NumberFormatInfo numberFormat = new CultureInfo("ko-KR", false).NumberFormat;

Console.WriteLine(price.ToString("c", numberFormat);

 

c 대신에 n을 넣으면 3자리씩 끊어서 출력한다.

ko-KR 통화표시 부분

 

ko-KR , en-US, ja-Jp 사용하면 국가별 표시 가능.



출처: https://podo1017.tistory.com/133 [Keep Moving]

 

[c#] 한국 원화 \ 표시하기.

참고 [ http://blog.naver.com/PostView.nhn?blogId=teshe&logNo=140055084055&widgetTypeCall=true ] 화면에 \3000 이렇게 표시하고 싶었는데 ""\\"" 를 사용하면 역슬래시만 표시 된다. 그래서 \를 표시하기 위..

podo1017.tistory.com

 

반응형
Posted by blueasa
, |

예전코드

 

string Pattern = @"^[a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ]*$";

 한글, 숫자, 영어는 커버가 가능했지만 대만에 퍼블리싱 되면서 대만어 입력을 할 경우 필터링 되어

 

문제가 되었는데 이와 같이 여러 언어로 서비스 하는 경우 각 국가 언어를 예전코드처럼 글자 자체를

 

입력하기에는 무리가 있다.

 

이런 경우 유니코드의 범위를 지정하여 필터링 할 수가 있는데 문제는 각 국가별 유니코드 범위를

 

알아야 한다는 것이었다. 아무리 구글신께 대만어 유니코드 범위를 알려달라 해봐도 그는 고개를

 

저을뿐..

 

 

검색을 이리저리 하다보니 CJK가 계속 눈에 띄어 위키느님께 여쭤보니

 

CJK(Chinese - Japanese - Korean, 중국·일본·한국)는 한국어, 중국어, 일본어를 통틀어 이르는 말로, 소프트웨어 국제화, 언어 지역화 분야에서 쓰인다. 베트남어를 포함해서 CJKV라고 하기도 한다.

으헉.. 한자는 중국과 대만이 다르고 또 한국과 일본이 다르건만 통합을 해놓았다...

 

내부적으로 어떤 경계가 있을법도 한데 어제 반나절을 투자해 검색해본 결과로는 없는것 같았다.

 

아마도 중복되는 한자들이 존재하니 통합하는길 밖에 없었던 것도 같다. 유니코드는 한 문자당 코드가

 

한개씩만 할당되어야 하므로.

 

알아낸 유니코드 범위들은 다음과 같다.

 

@"[\uFF21-\uFF3A]" // A-Z

@"[\uFF41-\uFF5A]"  // a-z
@"[\uFF10-\uFF19]"  // 0-9
@"[\uAC00-\uD7A3]"  // 가-힣
@"[\u1100-\u1112]"  // ㄱ-ㅎ
@"[\u3130-\u3163]"  // ㄱ-ㅎ(Compatible)ㅏ-ㅣ
@"[\u4E00-\u9FFF]" // Unified Hanja (Traditional/Simplify Chinese, Japanese, Korean)
@"[\u3040-\u30FC]" // Japanese 

 

실제 구현부에는 얘네들을 | 연산자로 국가별로 골라서 넣을 수 있도록 구현을 해놓았다.

 

아래 사이트에서 실제 어떤 아이들이 들어가 있는지 볼 수 있다.

http://en.wikibooks.org/wiki/Unicode/Character_reference/0000-0FFF

 

 

[출처] https://m.blog.naver.com/amurorei82/10189119746

 

C#에서의 나라별 정규 표현식 구현

예전코드 string Pattern = @"^[a-zA-Z0-9가-힣ㄱ-ㅎㅏ-ㅣ]*$"; 한글, 숫자, 영어는 커버가 가능했지만 ...

blog.naver.com

 

반응형
Posted by blueasa
, |

[출처] https://code.i-harness.com/ko-kr/q/5184a7

 

 

 

나는 @"^([\w\.\-]+)@([\w\-]+)((\.(\w))+)$" 가 효과가 있다고 생각합니다. 
당신은 그것을 쓸 필요가 있습니다.

string email = txtemail.Text;
Regex regex = new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w))+)$");
Match match = regex.Match(email);
if (match.Success)
    Response.Write(email + " is correct");
else
    Response.Write(email + " is incorrect");

다음 경우에 실패 할 것이라고 경고하십시오.

  1. @ 기호 다음에 하위 도메인이 있습니다.
  2. .info 와 같이 길이가 3보다 큰 TLD를 사용합니다.
 Question

나는 이것을 사용한다.

@"^([\w\.\-]+)@([\w\-]+)((\.(\w))+)$"

전자 우편의 유효성을 검사하는 regexp

([\w\.\-]+) - 첫 번째 수준 도메인 (많은 문자와 숫자, 점과 하이픈) 

([\w\-]+) - 두 번째 수준 도메인 용입니다. 

((\.(\w))+) 와)과 2 또는 3 리터럴을 포함하는 다른 레벨 도메인 (3에서 무한대까지)에 대한 것 ((\.(\w))+) 

이 정규식에 무슨 문제가 있습니까?

편집 : 그것은 "something@someth.ing"이메일과 일치하지 않습니다




 

Regex.IsMatch ()를 사용하고 있습니다.

우선 다음 문을 추가해야합니다.

using System.Text.RegularExpressions;

그런 다음 메서드는 다음과 같습니다.

private bool EmailValidation(string pEmail)
{
                 return Regex.IsMatch(pEmail,
                 @"^(?("")("".+?(?<!\\)""@)|(([0-9a-z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-z])@))" +
                 @"(?(\[)(\[(\d\.)\d\])|(([0-9a-z][-\w]*[0-9a-z]*\.)+[a-z0-9][\-a-z0-9][a-z0-9]))$",
                 RegexOptions.IgnoreCase, TimeSpan.FromMilliseconds(250));
}

그것은 내 논리 때문에 개인적인 방법이지만 "유틸리티"와 같은 다른 레이어에 정적으로 메서드를 넣고 필요한 곳에서 메서드를 호출 할 수 있습니다.




 

MSDN에 좋은 문서가 있습니다.

방법 : 문자열이 유효한 전자 메일 형식인지 확인 here (이 코드는 인터넷 도메인 이름에 비 ASCII 문자를 사용할 수도 있습니다. )

.NET 2.0 / 3.0 및 .Net 3.5 이상에서는 2 가지 구현이 있습니다. 
2.0 / 3.0 버전은 다음과 같습니다.

bool IsValidEmail(string strIn)
{
    // Return true if strIn is in valid e-mail format.
    return Regex.IsMatch(strIn, @"^([\w-\.]+)@((\[[0-9]\.[0-9]\.[0-9]\.)|(([\w-]+\.)+))([a-zA-Z]|[0-9])(\]?)$"); 
}

이 방법에 대한 내 테스트는 다음을 제공합니다.

Invalid: @majjf.com
Invalid: A@b@c@example.com
Invalid: Abc.example.com
Valid: j..s@proseware.com
Valid: j.@server1.proseware.com
Invalid: js*@proseware.com
Invalid: js@proseware..com
Valid: ma...ma@jjf.co
Valid: ma.@jjf.com
Invalid: ma@@jjf.com
Invalid: ma@jjf.
Invalid: ma@jjf..com
Invalid: ma@jjf.c
Invalid: ma_@jjf
Invalid: ma_@jjf.
Valid: ma_@jjf.com
Invalid: -------
Valid: 12@hostname.com
Valid: d.j@server1.proseware.com
Valid: david.jones@proseware.com
Valid: j.s@server1.proseware.com
Invalid: j@proseware.com9
Valid: j_9@[129.126.118.1]
Valid: jones@ms1.proseware.com
Invalid: js#internal@proseware.com
Invalid: js@proseware.com9
Invalid: js@proseware.com9
Valid: m.a@hostname.co
Valid: m_a1a@hostname.com
Valid: ma.h.saraf.onemore@hostname.com.edu
Valid: ma@hostname.com
Invalid: ma@hostname.comcom
Invalid: MA@hostname.coMCom
Valid: ma12@hostname.com
Valid: ma-a.aa@hostname.com.edu
Valid: ma-a@hostname.com
Valid: ma-a@hostname.com.edu
Valid: ma-a@1hostname.com
Valid: ma.a@1hostname.com
Valid: ma@1hostname.com



 

다음 코드는 github 에 대한 Microsoft의 데이터 주석 구현을 기반으로하며 전자 메일에 대한 가장 완전한 유효성 검사라고 생각합니다.

public static Regex EmailValidation()
{
    const string pattern = @"^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$";
    const RegexOptions options = RegexOptions.Compiled | RegexOptions.IgnoreCase | RegexOptions.ExplicitCapture;

    // Set explicit regex match timeout, sufficient enough for email parsing
    // Unless the global REGEX_DEFAULT_MATCH_TIMEOUT is already set
    TimeSpan matchTimeout = TimeSpan.FromSeconds(2);

    try
    {
        if (AppDomain.CurrentDomain.GetData("REGEX_DEFAULT_MATCH_TIMEOUT") == null)
        {
            return new Regex(pattern, options, matchTimeout);
        }
    }
    catch
    {
        // Fallback on error
    }

    // Legacy fallback (without explicit match timeout)
    return new Regex(pattern, options);
}



 

C #에서 REGEX 메서드를 사용하여 STRING 검색

정규 표현식으로 전자 메일의 유효성을 검사하는 방법

string EmailPattern = @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";
if (Regex.IsMatch(Email, EmailPattern, RegexOptions.IgnoreCase))
{
    Console.WriteLine("Email:  is valid.", Email);
}
else
{
    Console.WriteLine("Email:  is not valid.", Email);
}

Reference String.Regex () 메서드 사용




 
string patternEmail = @"(?<email>\w+@\w+\.[a-z])";
Regex regexEmail = new Regex(patternEmail);



 

이 코드는 C #에서 정규식을 사용하여 전자 메일 ID의 유효성을 검사하는 데 도움이됩니다. 닷넷 .. 사용하기 쉽습니다.

if (!System.Text.RegularExpressions.Regex.IsMatch("<Email String Here>", @"^([\w\.\-]+)@([\w\-]+)((\.(\w))+)$"))
        {
            MessageBox.show("Incorrect Email Id.");
        }



 

위 응답의 조합. MailAddress를 사용하는 Microsoft의 선호하는 방법을 사용하지만 문자열의 확장으로 구현합니다.

public static bool IsValidEmailAddress(this string emailaddress)
    {
        try
        {
            MailAddress m = new MailAddress(emailaddress);
            return true;
        }
        catch (FormatException)
        {
            return false;
        }
    }

그런 다음 모든 문자열을 이메일 주소로 확인하십시오.

string customerEmailAddress = "bert@potato.com";
customerEmailAddress.IsValidEmailAddress()

깨끗하고 간편한 휴대용. 누군가가 도움이되기를 바랍니다. 전자 메일의 정규식은 지저분합니다.

MattSwanson은이 주제에 대한 블로그를 갖고 있으며 정규식을 사용하지 말고 대신 '@'abd를 입력하는 것이 좋습니다. 여기에서 그의 설명을 읽으십시오 : https://mdswanson.com/blog/2013/10/14/how-not-to-validate-email-addresses.html




 

나는 당신의 캐럿과 달러 기호가 문제의 일부라고 생각한다. 정규 표현식을 약간 수정해야한다. 나는 다음 @ "[:] + ([\ w .-] +) @ ([\ w -.]) + ((. (\ w) ) +) "




 

크기에 대해 사용해보십시오.

public static bool IsValidEmailAddress(this string s)
{
    var regex = new Regex(@"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?");
    return regex.IsMatch(s);
}



 
public static bool ValidateEmail(string str)
{                       
     return Regex.IsMatch(str, @"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
}

위 코드를 사용하여 전자 메일 주소의 유효성을 검사합니다.




 

이것은 지금까지 내가 좋아하는 접근 방식입니다.

public static class CommonExtensions
{
    public static bool IsValidEmail(this string thisEmail)
        => !string.IsNullOrWhiteSpace(thisEmail) &&
           new Regex(@"^([\w\.\-]+)@([\w\-]+)((\.(\w))+)$").IsMatch(thisEmail);
}

그런 다음 생성 된 문자열 확장자를 다음과 같이 사용하십시오.

if (!emailAsString.IsValidEmail()) throw new Exception("Invalid Email");



 

이 기능을 사용해보십시오.

public bool IsValidEmailAddress(string s)
{
    if (string.IsNullOrEmpty(s))
        return false;
    else
    {
        var regex = new Regex(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*");
        return regex.IsMatch(s) && !s.EndsWith(".");
    }
}



 

최고의 이메일 검증 정규식

[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

그리고 그것의 사용법 : -

bool isEmail = Regex.IsMatch(emailString, @"\A(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?)\Z", RegexOptions.IgnoreCase);
 

 

반응형
Posted by blueasa
, |


[링크] http://codingcoding.tistory.com/382


반응형
Posted by blueasa
, |
  1.  
  2.         Dictionary<string, string> dict = new Dictionary<string, string>()
  3.         {
  4.             { "A""String A" },
  5.             { "B""String B" },
  6.             { "C""String C" },
  7.         };
  8.         string[] keys = new string[dict.Keys.Count];
  9.         dict.Keys.CopyTo(keys0);
  10.         for (int i = 0; i < keys.Length++i)
  11.         {
  12.             Debug.Log(dict[keys [i]]);
  13.         }
  14.  


[출처] https://forum.unity.com/threads/c-dictionary-loop.337804/

반응형
Posted by blueasa
, |
public static class Extensions
{
    public static bool TryGetKey<K, V>(this IDictionary<K, V> instance, V value, out K key)
    {
        foreach (var entry in instance)
        {
            if (!entry.Value.Equals(value))
            {
                continue;
            }
            key = entry.Key;
            return true;
        }
        key = default(K);
        return false;
    }
}

the usage is also so simple

int key = 0;
if (myDictionary.TryGetKey("twitter", out key))
{
    // successfully got the key :)
}



Link : http://stackoverflow.com/questions/4001908/get-dictionary-key-by-using-the-dictionary-value



[참조] https://www.dotnetperls.com/extension

반응형

'Programming > C#' 카테고리의 다른 글

C# 강의  (0) 2014.08.29
람다 식  (0) 2014.08.29
[C#] How to get/set using index for a Dictionary?  (0) 2014.08.06
NTP 서버에서 시간 가져오기(SNTP)  (0) 2014.07.14
C# 외부 프로그램 종료하기  (0) 2014.05.20
Posted by blueasa
, |
public class YourClass
{
    private readonly IDictionary<string, string> _yourDictionary = new Dictionary<string, string>();

    public string this[string key]
    {
        // returns value if exists
        get { return _yourDictionary[key]; }

        // updates if exists, adds if doesn't exist
        set { _yourDictionary[key] = value; }
    }
}





class SampleCollection<T>
{
    // Declare an array to store the data elements. 
    private T[] arr = new T[100];

    // Define the indexer, which will allow client code 
    // to use [] notation on the class instance itself. 
    // (See line 2 of code in Main below.)         
    public T this[int i]
    {
        get
        {
            // This indexer is very simple, and just returns or sets 
            // the corresponding element from the internal array. 
            return arr[i];
        }
        set
        {
            arr[i] = value;
        }
    }
}

// This class shows how client code uses the indexer. 
class Program
{
    static void Main(string[] args)
    {
        // Declare an instance of the SampleCollection type.
        SampleCollection<string> stringCollection = new SampleCollection<string>();

        // Use [] notation on the type.
        stringCollection[0] = "Hello, World";
        System.Console.WriteLine(stringCollection[0]);
    }
}
// Output: 
// Hello, World.


Link : http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx

반응형

'Programming > C#' 카테고리의 다른 글

람다 식  (0) 2014.08.29
Get Dictionary key by using the dictionary value  (0) 2014.08.12
NTP 서버에서 시간 가져오기(SNTP)  (0) 2014.07.14
C# 외부 프로그램 종료하기  (0) 2014.05.20
C# Keywords  (0) 2014.05.13
Posted by blueasa
, |