SELECT id, repo_name, path, content
FROM (
  SELECT f.id as id, repo_name, path, content
  FROM (
    SELECT id, repo_name, path
    FROM [bigquery-public-data:github_repos.files]
    WHERE LOWER(path) LIKE '%.java'
  ) AS f
  JOIN [bigquery-public-data:github_repos.contents] AS c
  ON f.id = c.id
) WHERE REGEXP_MATCH(content, r'((?i:String[\s]+\w+\([^\{]*long[^\{]+\)[\s]*\{[\s\S]+if[\s]*\([^<]+<[^\)]+\)[\s\S]*return[^;]+\+[^;]*\"\ B\"[\s\S]+int[\s][^\=]+\=[\s]*\([\s]*int[\s]*\)[\s]*\([\s]*Math[\s]*\.[\s]*log[\s]*\([^\)]+\)[\s]*\/[\s]*Math[\s]*\.[\s]*log[\s]*\([^\)]+\)[\s]*\)[\s\S]+return[^\}]+String[\s]*\.[\s]*format[\s]*\([^\}]+\}))');

--- Alternative query that shows the matches instead of the complete file contents:
SELECT *
FROM (
  SELECT id, repo_name, path, REGEXP_EXTRACT(content, r'((?i:String[\s]+\w+\([^\{]*long[^\{]+\)[\s]*\{[\s\S]+if[\s]*\([^<]+<[^\)]+\)[\s\S]*return[^;]+\+[^;]*\"\ B\"[\s\S]+int[\s][^\=]+\=[\s]*\([\s]*int[\s]*\)[\s]*\([\s]*Math[\s]*\.[\s]*log[\s]*\([^\)]+\)[\s]*\/[\s]*Math[\s]*\.[\s]*log[\s]*\([^\)]+\)[\s]*\)[\s\S]+return[^\}]+String[\s]*\.[\s]*format[\s]*\([^\}]+\}))') as match,
  FROM (
    SELECT f.id as id, repo_name, path, content
    FROM (
      SELECT id, repo_name, path
      FROM [bigquery-public-data:github_repos.files]
      WHERE LOWER(path) LIKE '%.java'
    ) AS f
    JOIN [bigquery-public-data:github_repos.contents] AS c
    ON f.id = c.id
  )
) WHERE LENGTH(match)>0;
