Using system.text.regularexpressions; using system.collections;
Namespace ccnuhome.toolsObject {///
Public string getfirstnchar (string instr, int firstn) {string outstr = ""; instr = instr.replace (@ "" "," "); regex r = new regex (@" ((? <=>) [/ W,.: "",. ""% ?! () @ ?! ()] * (? = <)) | ((? <= / b) [/ w,.: "",. ""% ?! () @ ?! ()] * (? = <)) | ((? <=>) [/ W,.: "",. ""% ?! () @ ?! ()] * ( ? = / b)) "); matchcollection mc = r.matches (instr); for (int i = 0; i Public arraylist gethref (string infutstring) {arraylist al = new arraylist (); regex r; match m; R = New Regex ("HREF // S * = // s * (?: /" ("<1> [^ /"] *) / "| (? <1> // s ))", regexoptions. Ignorecase | regexoptions.compiled; for (m = r.match (inputstring); m.success; m = m.nextmatch ()) {al.add (m.Groups [1] .value); } Return Al;} Public ArrayList GetImages (String InputString) {ArrayList Al = New ArrayList (); Regex R; Match M; R = New Regex ("IMG // S * SRC = /// s * (?: /" ("<1> [^ /"] *) / "| (? <1> // s )", RegexOptions .Ignorecase | regexoptions.compiled; for (m = r.match (inputstring); M.Success; m = m.nextMatch ()) {al.add (m.Groups [1] .value);} Return Al; } Public string getnimage (string infutstring, int index) {arraylist al = GetImages (InputString); return (string) al [index];}}}