#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
-#include "support/regex.h"
#include "support/textutils.h"
#include <map>
+#include <regex>
#include <set>
using namespace std;
// {\v a} to \v{a} (see #9340).
// FIXME: This is a sort of mini-tex2lyx.
// Use the real tex2lyx instead!
- static lyx::regex const tma_reg("^\\{\\\\[bcCdfGhHkrtuUv]\\s\\w\\}");
- if (lyx::regex_search(to_utf8(val), tma_reg)) {
+ static regex const tma_reg("^\\{\\\\[bcCdfGhHkrtuUv]\\s\\w\\}");
+ if (regex_search(to_utf8(val), tma_reg)) {
val = val.substr(1);
val.replace(2, 1, from_ascii("{"));
continue;
// look for that and change it, if necessary.
// FIXME: This is a sort of mini-tex2lyx.
// Use the real tex2lyx instead!
- static lyx::regex const reg("^\\\\\\W\\w");
- if (lyx::regex_search(to_utf8(val), reg)) {
+ static regex const reg("^\\\\\\W\\w");
+ if (regex_search(to_utf8(val), reg)) {
val.insert(3, from_ascii("}"));
val.insert(2, from_ascii("{"));
}
#include "support/Systemcall.h"
#include "support/os.h"
-#include "support/regex.h"
-
#include <fstream>
+#include <regex>
#include <stack>
#include "support/docstring.h"
#include "support/filetools.h"
#include "support/lstrings.h"
-#include "support/regex.h"
#include <algorithm>
+#include <regex>
using namespace std;
#include "support/FileName.h"
#include "support/filetools.h"
#include "support/lassert.h"
-
-#include "support/regex.h"
#include "support/TempFile.h"
#include <fstream>
+#include <regex>
using namespace std;
using namespace lyx::support;
#include "support/lassert.h"
#include "support/limited_stack.h"
#include "support/lstrings.h"
-#include "support/regex.h"
#include "mathed/InsetMathHull.h"
#include "mathed/InsetMathMacroTemplate.h"
#include "lyxfind.h"
#include <clocale>
+#include <regex>
#include <sstream>
using namespace std;
#include "support/lstrings.h"
#include "support/PathChanger.h"
#include "support/Systemcall.h"
-#include "support/regex.h"
#include "support/TempFile.h"
#include <fstream>
#include <iomanip>
+#include <regex>
#include <sstream>
using namespace std;
#undef KeyPress
-#include "support/regex.h"
-
#include <algorithm>
+#include <regex>
#include <string>
#include <vector>
{
// Search for all chars '.|*?+(){}[^$]\'
// Note that '[', ']', and '\' must be escaped.
- static const lyx::regex reg("[.|*?+(){}^$\\[\\]\\\\]");
+ static const regex reg("[.|*?+(){}^$\\[\\]\\\\]");
// $& is an ECMAScript format expression that expands to all
// of the current match
// To prefix a matched expression with a single literal backslash, we
// need to escape it for the C++ compiler and use:
// FIXME: UNICODE
- return from_utf8(lyx::regex_replace(to_utf8(expr), reg, string("\\$&")));
+ return from_utf8(regex_replace(to_utf8(expr), reg, string("\\$&")));
}
vector<docstring> GuiCitation::searchKeys(BiblioInfo const & bi,
vector<docstring> const & keys_to_search, bool only_keys,
docstring const & search_expression, docstring const & field,
- bool case_sensitive, bool regex)
+ bool case_sensitive, bool re)
{
vector<docstring> foundKeys;
if (expr.empty())
return foundKeys;
- if (!regex)
+ if (!re)
// We must escape special chars in the search_expr so that
- // it is treated as a simple string by lyx::regex.
+ // it is treated as a simple string by regex.
expr = escape_special_chars(expr);
- lyx::regex reg_exp;
+ regex reg_exp;
try {
reg_exp.assign(to_utf8(expr), case_sensitive ?
- lyx::regex_constants::ECMAScript : lyx::regex_constants::icase);
- } catch (lyx::regex_error const & e) {
- // lyx::regex throws an exception if the regular expression is not
+ regex_constants::ECMAScript : regex_constants::icase);
+ } catch (regex_error const & e) {
+ // regex throws an exception if the regular expression is not
// valid.
LYXERR(Debug::GUI, e.what());
return vector<docstring>();
continue;
try {
- if (lyx::regex_search(sdata, reg_exp))
+ if (regex_search(sdata, reg_exp))
foundKeys.push_back(*it);
}
- catch (lyx::regex_error const & e) {
+ catch (regex_error const & e) {
LYXERR(Debug::GUI, e.what());
return vector<docstring>();
}
// for FileFilter.
// FIXME: Remove
-#include "support/regex.h"
-
+#include <regex>
using namespace std;
using namespace lyx::support;
{
// Matches " *.{abc,def,ghi}", storing "*." as group 1 and
// "abc,def,ghi" as group 2, while allowing spaces in group 2.
- static lyx::regex const glob_re(" *([^ {]*)\\{([^}]+)\\}");
+ static regex const glob_re(" *([^ {]*)\\{([^}]+)\\}");
// Matches "abc" and "abc,", storing "abc" as group 1,
// while ignoring surrounding spaces.
- static lyx::regex const block_re(" *([^ ,}]+) *,? *");
+ static regex const block_re(" *([^ ,}]+) *,? *");
string pattern;
// Split data such as "TeX documents (*.tex);;LyX Documents (*.lyx)"
// into individual filters.
- static lyx::regex const separator_re(";;");
+ static regex const separator_re(";;");
string::const_iterator it = filter.begin();
string::const_iterator const end = filter.end();
while (true) {
match_results<string::const_iterator> what;
- if (!lyx::regex_search(it, end, what, separator_re)) {
+ if (!regex_search(it, end, what, separator_re)) {
parse_filter(string(it, end));
break;
}
{
// Matches "TeX documents (plain) (*.tex)",
// storing "TeX documents (plain) " as group 1 and "*.tex" as group 2.
- static lyx::regex const filter_re("(.*)\\(([^()]+)\\) *$");
+ static regex const filter_re("(.*)\\(([^()]+)\\) *$");
match_results<string::const_iterator> what;
- if (!lyx::regex_search(filter, what, filter_re)) {
+ if (!regex_search(filter, what, filter_re)) {
// Just a glob, no description.
filters_.push_back(Filter(docstring(), trim(filter)));
} else {
#include <iostream>
#include <map>
-
-#include "support/regex.h"
+#include <regex>
using namespace std;
{
// Search for all chars '.|*?+(){}[^$]\'
// Note that '[', ']', and '\' must be escaped.
- lyx::regex reg("[.|*?+(){}^$\\[\\]\\\\]");
+ regex reg("[.|*?+(){}^$\\[\\]\\\\]");
// $& is a ECMAScript format expression that expands to all
// of the current match
// To prefix a matched expression with a single literal backslash, we
// need to escape it for the C++ compiler and use:
- return lyx::regex_replace(expr, reg, "\\$&");
+ return regex_replace(expr, reg, "\\$&");
}
// Attempts to find a match for the current RE
// somewhere in data.
- return lyx::regex_search(data, regex_);
+ return regex_search(data, regex_);
}
private:
InfoMap const map_;
- mutable lyx::regex regex_;
+ mutable regex regex_;
};
cout << rm("hello") << endl;
cout << rm("hei") << endl;
}
- catch (lyx::regex_error & regerr) {
+ catch (regex_error & regerr) {
cout << regerr.what() << endl;
}
}
#include "support/docstream.h"
#include "support/filetools.h"
#include "support/FileName.h"
-#include "support/regex.h"
+
+#include <regex>
using namespace std;
using namespace lyx::support;
return string();
}
- static lyx::regex bbox_re("^%%BoundingBox:\\s*([-]*[[:digit:]]+)"
+ static regex bbox_re("^%%BoundingBox:\\s*([-]*[[:digit:]]+)"
"\\s+([-]*[[:digit:]]+)\\s+([-]*[[:digit:]]+)\\s+([-]*[[:digit:]]+)");
ifstream is(file_.toFilesystemEncoding().c_str());
while (is) {
string s;
getline(is,s);
- lyx::smatch what;
+ smatch what;
if (regex_match(s, what, bbox_re)) {
// Our callers expect the tokens in the string
// separated by single spaces.
#include "support/lyxlib.h" // float_equal
#include "support/Translator.h"
-#include "support/regex.h"
-
#include <cmath> // abs
+#include <regex>
#include <sstream>
using namespace std;
// Strip any leading commas
// "[,,,,foo..." -> "foo..." ("foo..." may be empty)
string output;
- lyx::smatch what;
- static lyx::regex const front("^( *\\[,*)(.*)$");
+ smatch what;
+ static regex const front("^( *\\[,*)(.*)$");
if (!regex_match(it, end, what, front)) {
lyxerr << "Unable to sanitize LaTeX \"Option\": "
// Replace any consecutive commas with a single one
// "foo,,,,bar" -> "foo,bar"
// with iterator now pointing to 'b'
- static lyx::regex const commas("([^,]*)(,,*)(.*)$");
+ static regex const commas("([^,]*)(,,*)(.*)$");
for (; it != end;) {
if (!regex_match(it, end, what, commas)) {
output += string(it, end);
// Strip any trailing commas
// "...foo,,,]" -> "...foo" ("...foo,,," may be empty)
- static lyx::regex const back("^(.*[^,])?,*\\] *$");
+ static regex const back("^(.*[^,])?,*\\] *$");
if (!regex_match(output, what, back)) {
lyxerr << "Unable to sanitize LaTeX \"Option\": "
<< output << '\n';
#include "support/ExceptionMessage.h"
#include "support/FileNameList.h"
#include "support/filetools.h"
-#include "support/regex.h"
#include "support/gettext.h"
#include "support/lstrings.h"
#include "support/os.h"
#include <limits>
#include <map>
+#include <regex>
#include <utility>
#include <iostream>
string html = to_utf8(bibinfo.getInfo(entry.key(), buffer(), ci));
regex tagRegex("<span class=\"bib-([^\"]*)\">([^<]*)</span>");
smatch match;
- auto tagIt = lyx::sregex_iterator(html.cbegin(), html.cend(), tagRegex, regex_constants::match_default);
- auto tagEnd = lyx::sregex_iterator();
+ auto tagIt = sregex_iterator(html.cbegin(), html.cend(), tagRegex, regex_constants::match_default);
+ auto tagEnd = sregex_iterator();
map<string, string> delayedTags;
// Read all tags from HTML and convert those that have a 1:1 matching.
#include "frontends/alert.h"
#include "frontends/Application.h"
-#include "support/regex.h"
-
+#include <regex>
#include <sstream>
using namespace std;
#include "support/gettext.h"
#include "support/lassert.h"
#include "support/lstrings.h"
-
-#include "support/regex.h"
#include "support/textutils.h"
+
#include <map>
+#include <regex>
using namespace std;
using namespace lyx::support;
bool regex_replace(string const & s, string & t, string const & searchstr,
string const & replacestr)
{
- lyx::regex e(searchstr, regex_constants::ECMAScript);
+ regex e(searchstr, regex_constants::ECMAScript);
ostringstream oss;
ostream_iterator<char, char> it(oss);
- lyx::regex_replace(it, s.begin(), s.end(), e, replacestr);
+ regex_replace(it, s.begin(), s.end(), e, replacestr);
// tolerate t and s be references to the same variable
bool rv = (s != oss.str());
t = oss.str();
// normalized string to search
string par_as_string;
// regular expression to use for searching
- lyx::regex regexp;
+ regex regexp;
// same as regexp, but prefixed with a ".*?"
- lyx::regex regexp2;
+ regex regexp2;
// leading format material as string
string lead_as_string;
// par_as_string after removal of lead_as_string
// @TODO Support \item[text]
// Kornel: Added textsl, textsf, textit, texttt and noun
// + allow to search for colored text too
- while (regex_replace(t, t, REGEX_BOS "\\\\(((footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage|latexenvironment)\\{[a-z]+\\*?\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{", "")
- || regex_replace(t, t, REGEX_BOS "\\$", "")
- || regex_replace(t, t, REGEX_BOS "\\\\\\[", "")
- || regex_replace(t, t, REGEX_BOS " ?\\\\item\\{[a-z]+\\}", "")
- || regex_replace(t, t, REGEX_BOS "\\\\begin\\{[a-zA-Z_]*\\*?\\}", ""))
+ while (regex_replace(t, t, "^\\\\(((footnotesize|tiny|scriptsize|small|large|Large|LARGE|huge|Huge|emph|noun|minisec|text(bf|md|sl|sf|it|tt))|((textcolor|foreignlanguage|latexenvironment)\\{[a-z]+\\*?\\})|(u|uu)line|(s|x)out|uwave)|((sub)?(((sub)?section)|paragraph)|part|chapter)\\*?)\\{", "")
+ || regex_replace(t, t, "^\\$", "")
+ || regex_replace(t, t, "^\\\\\\[", "")
+ || regex_replace(t, t, "^ ?\\\\item\\{[a-z]+\\}", "")
+ || regex_replace(t, t, "^\\\\begin\\{[a-zA-Z_]*\\*?\\}", ""))
;
LYXERR(Debug::FIND, " after removing leading $, \\[ , \\emph{, \\textbf{, etc.: '" << t << "'");
return s.find(t);
int open_braces = 0;
do {
LYXERR(Debug::FIND, "identifyClosing(): t now is '" << t << "'");
- if (regex_replace(t, t, "(.*[^\\\\])\\$" REGEX_EOS, "$1"))
+ if (regex_replace(t, t, "(.*[^\\\\])\\$$", "$1"))
continue;
- if (regex_replace(t, t, "(.*[^\\\\])\\\\\\]" REGEX_EOS, "$1"))
+ if (regex_replace(t, t, "(.*[^\\\\])\\\\\\]$", "$1"))
continue;
- if (regex_replace(t, t, "(.*[^\\\\])\\\\end\\{[a-zA-Z_]*\\*?\\}" REGEX_EOS, "$1"))
+ if (regex_replace(t, t, "(.*[^\\\\])\\\\end\\{[a-zA-Z_]*\\*?\\}$", "$1"))
continue;
- if (regex_replace(t, t, "(.*[^\\\\])\\}" REGEX_EOS, "$1")) {
+ if (regex_replace(t, t, "(.*[^\\\\])\\}$", "$1")) {
++open_braces;
continue;
}
regexp2_str = "(" + lead_as_regexp + ").*?" + par_as_string;
}
LYXERR(Debug::FIND, "Setting regexp to : '" << regexp_str << "'");
- regexp = lyx::regex(regexp_str);
+ regexp = regex(regexp_str);
LYXERR(Debug::FIND, "Setting regexp2 to: '" << regexp2_str << "'");
- regexp2 = lyx::regex(regexp2_str);
+ regexp2 = regex(regexp2_str);
}
}
pmprof.h \
qstring_helpers.cpp \
qstring_helpers.h \
- regex.h \
signals.h \
socktools.cpp \
socktools.h \
#include <QDir>
#include "support/lassert.h"
-#include "support/regex.h"
#include <fcntl.h>
#ifdef HAVE_MAGIC_H
#include <utility>
#include <fstream>
+#include <regex>
#include <sstream>
#include <vector>
#include "support/debug.h"
#include "support/filetools.h"
#include "support/qstring_helpers.h"
-#include "support/regex.h"
#include <QDir>
+#include <regex>
+
#if defined(__CYGWIN__)
#include "support/os_cygwin.cpp"
#elif defined(_WIN32)
+++ /dev/null
-// -*- C++ -*-
-/**
- * \file regexp.h
- * This file is part of LyX, the document processor.
- * Licence details can be found in the file COPYING.
- *
- * \author Peter Kümmel
- *
- * Full author contact details are available in file CREDITS.
- */
-
-#ifndef LYX_REGEXP_H
-#define LYX_REGEXP_H
-
-#include <regex>
-
-namespace lyx {
-
-using std::regex;
-using std::regex_match;
-using std::regex_replace;
-using std::regex_search;
-using std::sregex_iterator;
-using std::smatch;
-using std::basic_regex;
-using std::regex_error;
-using std::match_results;
-
-namespace regex_constants
-{
-
-using namespace std::regex_constants;
-using std::regex_constants::match_flag_type;
-
-} // namespace regex_constants
-
-} // namespace lyx
-
-// Match Begin and End of String when using ECMAScript (default std::regex)
-#define REGEX_BOS "^"
-#define REGEX_EOS "$"
-
-#endif // LYX_REGEXP_H
#include <config.h>
#include "../support/debug.h"
-#include "../support/regex.h"
#include <iostream>
+#include <regex>
using namespace lyx;
#include "support/filetools.h"
#include "support/lstrings.h"
-#include "support/regex.h"
-
#include <algorithm>
#include <iostream>
+#include <regex>
using namespace std;
using namespace lyx::support;