Find a first {tag} in the string.
543598
function (expression, s) {
      var openCount = 0
      var offset = 0
      var i
      var ldelim = this.ldelim
      var rdelim = this.rdelim
      var skipInWhitespace = this.autoLiteral
      var expressionAny = /^\s*(.+)\s*$/i
      var expressionTag = expression ? new RegExp('^\\s*(' + expression + ')\\s*$', 'i') : expressionAny
      var sTag
      var found

      for (i = 0; i < s.length; ++i) {
        if (s.substr(i, ldelim.length) === ldelim) {
          if (skipInWhitespace && (i + 1) < s.length && s.substr((i + 1), 1).match(/\s/)) {
            continue
          }
          if (!openCount) {
            s = s.slice(i)
            offset += parseInt(i)
            i = 0
          }
          ++openCount
        } else if (s.substr(i, rdelim.length) === rdelim) {
          if (skipInWhitespace && (i - 1) >= 0 && s.substr((i - 1), 1).match(/\s/)) {
            continue
          }
          if (!--openCount) {
            sTag = s.slice(ldelim.length, i).replace(/[\r\n]/g, ' ')
            found = sTag.match(expressionTag)
            if (found) {
              found.index = offset
              found[0] = s.slice(0, (i + rdelim.length))
              return found
            }
          }
          if (openCount < 0) {
            // Ignore any number of unmatched right delimiters.
            openCount = 0
          }
        }
      }
      return null
    }
829398
def start_tag(self) -> str:
        """"""
        tag = '<' + self.tag
        attrs = self._get_attrs_by_string()
        if attrs:
            tag = ' '.join((tag, attrs))
        return tag + '>'
1215593
function (tagName, tokens, i) {
            // if a tagName is provided, use that
            if (tagName) {
                return tagName;
            } else {
                // otherwise go searching for the next two tokens like "<",TAG
                while (i < tokens.length) {
                    if (tokens[i] == "<" && reverseTagMap[tokens[i + 1]]) {
                        return reverseTagMap[tokens[i + 1]];
                    }
                    i++;
                }
            }
            return '';
        }
1338283
function firstStrongChar(str: string): ?string {
  const match = REGEX_STRONG.exec(str);
  return match == null ? null : match[0];
}
90198
def findFirstHref(link_attrs_list, target_rel):
    """"""
    # XXX: TESTME
    matches = findLinksRel(link_attrs_list, target_rel)
    if not matches:
        return None
    first = matches[0]
    return first.get('href')
528323
function findNextHTMLItem(editor) {
		var isFirst = true;
		return findItem(editor, false, function(content, searchPos){
			if (isFirst) {
				isFirst = false;
				return findOpeningTagFromPosition(content, searchPos);
			} else {
				return getOpeningTagFromPosition(content, searchPos);
			}
		}, function(tag, offset, selRange) {
			return getRangeForHTMLItem(tag, offset, selRange, false);
		});
	}
312556
def handle_starttag(self, tag, attrs):
        """"""
        if not tag == 'a':
            return

        for attr in attrs:
            if attr[0] == 'href':
                # Links look like: /pub/firefox/nightly/2015/
                # We have to trim the fragment down to the last item. Also to ensure we
                # always get it, we remove a possible final slash first
                url = urllib.unquote(attr[1])
                self.active_url = url.rstrip('/').split('/')[-1]

                return
616154
private String getNextTag(String str) {
        String tag;
        int endIndex;
        int tagIndex = str.indexOf("(");

        if( tagIndex < 0 ) {
            return null;
        }

        // in case there's nothing in the sentence
        endIndex = str.indexOf(" ", tagIndex);

        if( endIndex < 0 ) {
            return null;
        }

        tag = str.substring( tagIndex+1, endIndex ); 

        if( tag.length() > 0 ) {
            return tag;
        } else {
            str = str.substring( tagIndex+1 );
            return getNextTag(str);
        }
    }
53570
def start_tag(self, alt=None, empty=False):
        """"""
        if alt:
            name = alt
        else:
            name = self.name
        result = "<" + name
        for it in self.attr:
            result += ' %s="%s"' % (it, escape(self.attr[it], {'"':"&quot;", '%': "%%"}))
        if empty:
            return result + "/>%s"
        else:
            return result + ">"
193345
function parseEndTag(tag, tagName) {

      // If no tag name is provided, clean shop
      if (!tagName)
        var pos = 0;

      // Find the closest opened tag of the same type
      else {
        tagName = tagName.toLowerCase();
        for (var pos = stack.length - 1; pos >= 0; pos--)
          if (stack[pos] == tagName)
            break;
      }

      if (pos >= 0) {
        // Close all the open elements, up the stack
        for (var i = stack.length - 1; i >= pos; i--)
          results += "</" + stack[i] + ">";

        // Remove the open elements from the stack
        stack.length = pos;
      }

    }
157783
def parse_tag_pattern(self, sel, m, has_selector):
        """"""

        parts = [css_unescape(x) for x in m.group(0).split('|')]
        if len(parts) > 1:
            prefix = parts[0]
            tag = parts[1]
        else:
            tag = parts[0]
            prefix = None
        sel.tag = ct.SelectorTag(tag, prefix)
        has_selector = True
        return has_selector
218625
private int findFirst(CharSequence input, int beginIndex, int rewindIndex) {
        int first = -1;
        boolean atomBoundary = true;
        for (int i = beginIndex; i >= rewindIndex; i--) {
            char c = input.charAt(i);
            if (localAtomAllowed(c)) {
                first = i;
                atomBoundary = false;
            } else if (c == '.') {
                if (atomBoundary) {
                    break;
                }
                atomBoundary = true;
            } else {
                break;
            }
        }
        return first;
    }
1141090
def find_by_tag(self, tag) -> Dict[str, Set[Parameter]]:
        
        return self.tags[tag]
39484
public String getFirstPriorityTag(List<String> restrictions) {
        for (String str : restrictions) {
            if (hasTag(str))
                return getTag(str);
        }
        return "";
    }
1050816
private static String lcFirst(String s)
    {
        if (s == null || s.isEmpty())
        {
            return s;
        }

        return Character.toLowerCase(s.charAt(0))
                + (s.length() == 1 ? "" : s.substring(1));
    }
1263017
def tag(self, name: str) -> models.Tag:
        """"""
        return self.Tag.filter_by(name=name).first()
723021
private int findLast(CharSequence input, int beginIndex) {
        boolean firstInSubDomain = true;
        boolean canEndSubDomain = false;
        int firstDot = -1;
        int last = -1;
        for (int i = beginIndex; i < input.length(); i++) {
            char c = input.charAt(i);
            if (firstInSubDomain) {
                if (subDomainAllowed(c)) {
                    last = i;
                    firstInSubDomain = false;
                    canEndSubDomain = true;
                } else {
                    break;
                }
            } else {
                if (c == '.') {
                    if (!canEndSubDomain) {
                        break;
                    }
                    firstInSubDomain = true;
                    if (firstDot == -1) {
                        firstDot = i;
                    }
                } else if (c == '-') {
                    canEndSubDomain = false;
                } else if (subDomainAllowed(c)) {
                    last = i;
                    canEndSubDomain = true;
                } else {
                    break;
                }
            }
        }
        if (domainMustHaveDot && (firstDot == -1 || firstDot > last)) {
            return -1;
        } else {
            return last;
        }
    }