public RelabelNode(TsurgeonPattern child, string newLabel) : base("relabel", new TsurgeonPattern[] { child }) { // Overly complicated pattern to identify regexes surrounded by /, // possibly with / escaped inside the regex. // The purpose of the [^/]*[^/\\\\] is to match characters that // aren't / and to allow escaping of other characters. // The purpose of the \\\\/ is to allow escaped / inside the pattern. // The purpose of the \\\\\\\\ is to allow escaped \ at the end of // the pattern, so you can match, for example, /\\/. There need to // be 8x\ because both java and regexes need escaping, resulting in 4x. Java.Util.Regex.Matcher m1 = substPattern.Matcher(newLabel); if (m1.Matches()) { mode = RelabelNode.RelabelMode.Regex; this.labelRegex = Pattern.Compile(m1.Group(1)); this.replacementString = m1.Group(2); replacementPieces = new List <string>(); Java.Util.Regex.Matcher generalMatcher = oneGeneralReplacementPattern.Matcher(m1.Group(2)); int lastPosition = 0; while (generalMatcher.Find()) { if (generalMatcher.Start() > lastPosition) { replacementPieces.Add(Sharpen.Runtime.Substring(replacementString, lastPosition, generalMatcher.Start())); } lastPosition = generalMatcher.End(); string piece = generalMatcher.Group(); if (piece.Equals(string.Empty)) { continue; } replacementPieces.Add(generalMatcher.Group()); } if (lastPosition < replacementString.Length) { replacementPieces.Add(Sharpen.Runtime.Substring(replacementString, lastPosition)); } this.newLabel = null; } else { mode = RelabelNode.RelabelMode.Fixed; Java.Util.Regex.Matcher m2 = regexPattern.Matcher(newLabel); if (m2.Matches()) { // fixed relabel but surrounded by regex slashes string unescapedLabel = m2.Group(1); this.newLabel = RemoveEscapeSlashes(unescapedLabel); } else { // just a node name to relabel to this.newLabel = newLabel; } this.replacementString = null; this.replacementPieces = null; this.labelRegex = null; } }
/** * \brief Create the media player and load video */ private void createMediaPlayer() { mMediaPlayerLock.Lock(); mMediaControllerLock.Lock(); mMediaPlayer = new MediaPlayer(); mMediaController = new MediaController(this); AssetFileDescriptor afd = null; bool fileExist = true; try { afd = Assets.OpenFd(mMovieUrl); } catch (IOException e) { fileExist = false; } if (afd == null) { fileExist = false; } try { if (fileExist) { mMediaPlayer.SetDataSource(afd.FileDescriptor, afd.StartOffset, afd.Length); afd.Close(); } else { string URL_REGEX = "^((https?|ftp)://|(www|ftp)\\.)[a-z0-9-]+(\\.[a-z0-9-]+)+((:[0-9]+)|)+([/?].*)?$"; //should be ok Java.Util.Regex.Pattern p = Java.Util.Regex.Pattern.Compile(URL_REGEX); Java.Util.Regex.Matcher m = p.Matcher(mMovieUrl); //replace with string to compare if (m.Find()) { mMediaPlayer.SetDataSource(mMovieUrl); } } mMediaPlayer.SetDisplay(mHolder); mMediaPlayer.PrepareAsync(); mMediaPlayer.SetOnPreparedListener(this); mMediaPlayer.SetOnErrorListener(this); mMediaPlayer.SetOnCompletionListener(this); mMediaPlayer.SetAudioStreamType(Stream.Music); } catch (Exception e) { Log.Error("PikkartFullscreenVideo", "error while creating the MediaPlayer: " + e.ToString()); prepareForTermination(); destroyMediaPlayer(); Finish(); } mMediaControllerLock.Unlock(); mMediaPlayerLock.Unlock(); }
private bool Check(string openload, string str) { Java.Util.Regex.Pattern pattern = Java.Util.Regex.Pattern.Compile(openload, Java.Util.Regex.RegexOptions.CaseInsensitive); Java.Util.Regex.Matcher matcher = pattern.Matcher(str); return(matcher.Find()); }