codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
public string keywords = ("uses|var|array|of|BEGIN|FOR|For|to|do|Begin|end|END|IF|then"); public string keywords2 = ("0|1|2|3|4|5|6|7|8|9"); public void updatekeyword() { string UserAddKeyWord = txtGetText.Text; keywords = string.Concat(keywords, UserAddKeyWord); } private void rtbPascal_TextChanged(object sender, EventArgs e) { highlight(); } private void highlight() { updatekeyword(); Regex rex1 = new Regex(keywords); int StartPoint = rtbPascal.SelectionStart; foreach (Match KeywordMatch in rex1.Matches(rtbPascal.Text)) { rtbPascal.Select(KeywordMatch.Index, KeywordMatch.Length); rtbPascal.SelectionColor = Color.Blue; rtbPascal.SelectionStart = StartPoint; rtbPascal.SelectionColor = Color.Black; } Regex rex2 = new Regex(keywords2); foreach (Match KeywordMatch2 in rex2.Matches(rtbPascal.Text)) { rtbPascal.Select(KeywordMatch2.Index, KeywordMatch2.Length); rtbPascal.SelectionColor = Color.Orange; rtbPascal.SelectionStart = StartPoint; rtbPascal.SelectionColor = Color.Black; } }
Private
[
?
]
Run code
Submit