I am trying to identify and condense single (uppercase) characters in a string.
For instance:
"test AB test" → "test AB test"
"test ABC test" → "test ABC test"
"test AB test CDE test" → "test AB test CDE test"
It works for me for individual occurrences (as in the first example above), but cannot figure out how to link it for several occurrences.
$str =~ s/ ([A-Z]) ([A-Z]) / \1\2 /g;
I will probably feel stupid when I see a solution, but I'm ready for it. Thanks in advance.
$str =~ s/\b([A-Z])\s+(?=[A-Z]\b)/$1/g;
, , , . "A B C" "AB C", B - A.
s/([A-Z]) ([A-Z])/\1\2/g, , (, " " → "THISISATEST" ), .
s/([A-Z]) ([A-Z])/\1\2/g
, (, " IMA" → " IMA", "" ), , . , , , - (, " IMA" → " ^ M ^ A TEST" → " IMA TEST" ), , , , , .
Source: https://habr.com/ru/post/1745845/More articles:Download Silverlight: is it safe? - uploadlanguage virtual keyboard with java - javaJava: невозможно выполнить runnable в тестовом примере: void run() сталкивается - javaC # System.Xml.Serialization Nested Elements - c #Applying an iterative algorithm to a set of rows from a database - phpTypedef naming for boost :: shared_ptr - c ++How to send a file using secure FTP protocol SSL - phpTwitter xAuth vs. open source - open-sourceNew Objective C Developer Question - objective-cPHP Checking slave status without timeouts mysql_connect - phpAll Articles