Home > front end >  For a regular expression to replace all the first character from the beginning
For a regular expression to replace all the first character from the beginning

Time:10-02

ABCDEFG CK020 # - database - 123546 Test - Test

For a regular expression to replace the first character - after all the content (any character)

CodePudding user response:

String: ABCDEFG - database CK020 # - 123546 Test - Test
Output: ABCDEFG

CodePudding user response:

Any characters including Spaces newline brackets?

CodePudding user response:

refer to the second floor sky waves reply:
any newline characters, including Spaces brackets?
including,

CodePudding user response:

good reference 3 floor p-code response:
Quote: refer to the second floor of the sky wave response:

Any characters including Spaces newline brackets?
,

The replace (/] [\ W \ W +/g, "")

CodePudding user response:

 $pattern='/-. * \ s/'; 
$replacement=' ';
$subject="ABCDEFG - several according to library CK020 # - 123546 Test - Test \ n";
$subject=preg_replace ($pattern, $replacement, $subject);
Var_dump ($subject);

//the OUTPUT:
//string (7) "ABCDEFG"

CodePudding user response:

The
reference 5 floor body established under the pine reply:
 $pattern='/-. * \ s/'; 
$replacement=' ';
$subject="ABCDEFG - several according to library CK020 # - 123546 Test - Test \ n";
$subject=preg_replace ($pattern, $replacement, $subject);
Var_dump ($subject);

//the OUTPUT:
//string (7) "ABCDEFG"

 var string=new string (" ABCDEFG CK020 # - database - 123546 Test - Test \ r \ n "); 
Var regexp=new regexp (" -. * [\ n \ r] * ", "gi");
String. The replace (regexp, "");
"ABCDEFG"

CodePudding user response:

STR. The split (' - ') [0]
Don't have to be with regular
  • Related