17 using System.Collections.Generic;
18 using System.Text.RegularExpressions;
22 namespace Deveel.Data.Text {
27 #region Public Methods
28 public bool RegexMatch(
string regularExpression,
string expressionOps,
string value) {
29 RegexOptions options = RegexOptions.None;
31 if (expressionOps != null) {
32 if (expressionOps.IndexOf(
'i') != -1) {
33 options |= RegexOptions.IgnoreCase;
35 if (expressionOps.IndexOf(
's') != -1) {
36 options |= RegexOptions.Singleline;
38 if (expressionOps.IndexOf(
'm') != -1) {
39 options |= RegexOptions.Multiline;
43 Regex regex =
new Regex(regularExpression, options);
44 return regex.IsMatch(value);
47 public IList<int>
RegexSearch(Table table,
int column,
string regularExpression,
string expressionOps) {
49 IList<int> row_list = table.SelectAll(column);
51 List<int> result_list =
new List<int>();
57 RegexOptions options = RegexOptions.None;
58 if (expressionOps != null) {
59 if (expressionOps.IndexOf(
'i') != -1) {
60 options |= RegexOptions.IgnoreCase;
62 if (expressionOps.IndexOf(
's') != -1) {
63 options |= RegexOptions.Singleline;
65 if (expressionOps.IndexOf(
'm') != -1) {
66 options |= RegexOptions.Multiline;
70 regex =
new Regex(regularExpression, options);
77 int size = row_list.Count;
78 for (
int i = 0; i < size; ++i) {
79 int row_index = row_list[i];
80 TObject cell = table.GetCell(column, row_index);
83 Object ob = cell.Object;
84 String str = ob.ToString();
86 if (regex.IsMatch(str)) {
87 result_list.Add(row_index);
The default implementation of the system regular expression library.
An interface that links with a Regex library.
bool RegexMatch(string regularExpression, string expressionOps, string value)
Matches a regular expression against a string value.
IList< int > RegexSearch(Table table, int column, string regularExpression, string expressionOps)
Performs a regular expression search on the given column of the table.