 |
|
สอบถามเรื่องการแบ่งคำ โดยใช้ Character เป็น key หน่อยครับ |
|
 |
|
|
 |
 |
|
แยกแบบนี้รึป่าวครับ

Code (C#)
string strRegex = @"(.*?)\s{1,}";
Regex myRegex = new Regex(strRegex, RegexOptions.None);
string strTargetString = @"TEST1 TEST2 TEST3 TEST4 TEST5 ";
foreach (Match myMatch in myRegex.Matches(strTargetString))
{
if (myMatch.Success)
{
// Add your code here
}
}
|
 |
 |
 |
 |
Date :
2018-06-26 13:56:03 |
By :
lamaka.tor |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองดูโค้ดนี้เป็นตัวอย่างครับ
using System;
public class Example
{
public static void Main()
{
string[] separators = {",", ".", "!", "?", ";", ":", " "};
string value = "The handsome, energetic, young dog was playing with his smaller, more lethargic litter mate.";
string[] words = value.Split(separators, StringSplitOptions.RemoveEmptyEntries);
foreach (var word in words)
Console.WriteLine(word);
}
}
// The example displays the following output:
// The
// handsome
// energetic
// young
// dog
// was
// playing
// with
// his
// smaller
// more
// lethargic
// litter
// mate
|
 |
 |
 |
 |
Date :
2018-06-27 17:40:20 |
By :
Rashun |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|