aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe-external-packages/src/symfony/console/helper
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe-external-packages/src/symfony/console/helper')
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/helper.rs14
-rw-r--r--crates/shirabe-external-packages/src/symfony/console/helper/table.rs4
2 files changed, 11 insertions, 7 deletions
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs b/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs
index be5eb050..20103df8 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/helper.rs
@@ -3,6 +3,7 @@
use crate::symfony::console::formatter::output_formatter_interface::OutputFormatterInterface;
use crate::symfony::console::helper::helper_set::HelperSet;
use crate::symfony::string::unicode_string::UnicodeString;
+use shirabe_php_shim::php_regex;
/// Helper is the base class for all helper classes.
#[derive(Debug, Default)]
@@ -39,7 +40,7 @@ impl Helper {
/// Returns the width of a string, using mb_strwidth if it is available.
/// The width is how many characters positions the string will use.
pub fn width(string: &str) -> i64 {
- if shirabe_php_shim::preg_match("//u", string, &mut Vec::new()) {
+ if shirabe_php_shim::preg_match(php_regex!("//u"), string, &mut Vec::new()) {
return UnicodeString::new(string).width(false);
}
@@ -55,7 +56,7 @@ impl Helper {
/// Returns the length of a string, using mb_strlen if it is available.
/// The length is related to how many bytes the string will use.
pub fn length(string: &str) -> i64 {
- if shirabe_php_shim::preg_match("//u", string, &mut Vec::new()) {
+ if shirabe_php_shim::preg_match(php_regex!("//u"), string, &mut Vec::new()) {
return UnicodeString::new(string).length();
}
@@ -147,10 +148,13 @@ impl Helper {
// remove <...> formatting
let string = formatter.format(Some(string)).unwrap().unwrap_or_default();
// remove already formatted characters
- let string = shirabe_php_shim::preg_replace("/\u{1b}\\[[^m]*m/", "", &string);
+ let string = shirabe_php_shim::preg_replace(php_regex!("/\u{1b}\\[[^m]*m/"), "", &string);
// remove terminal hyperlinks
- let string =
- shirabe_php_shim::preg_replace("/\u{1b}]8;[^;]*;[^\u{1b}]*\u{1b}\\\\/", "", &string);
+ let string = shirabe_php_shim::preg_replace(
+ php_regex!("/\u{1b}]8;[^;]*;[^\u{1b}]*\u{1b}\\\\/"),
+ "",
+ &string,
+ );
formatter.set_decorated(is_decorated);
string
diff --git a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
index cae3f896..c5d7e346 100644
--- a/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
+++ b/crates/shirabe-external-packages/src/symfony/console/helper/table.rs
@@ -14,7 +14,7 @@ use crate::symfony::console::helper::table_style::TableStyle;
use crate::symfony::console::output::console_section_output::ConsoleSectionOutput;
use crate::symfony::console::output::output_interface::OutputInterface;
use indexmap::IndexMap;
-use shirabe_php_shim::PhpMixed;
+use shirabe_php_shim::{PhpMixed, php_regex};
/// A single cell within a table row.
///
@@ -847,7 +847,7 @@ impl Table {
let mut pad_type = style.get_pad_type();
if cell.is_table_cell() && cell.style().is_some() {
let is_not_styled_by_tag = !Preg::is_match(
- "/^<(\\w+|(\\w+=[\\w,]+;?)*)>.+<\\/(\\w+|(\\w+=\\w+;?)*)?>$/",
+ php_regex!("/^<(\\w+|(\\w+=[\\w,]+;?)*)>.+<\\/(\\w+|(\\w+=\\w+;?)*)?>$/"),
&cell_str,
);
if is_not_styled_by_tag {