text:
Is this string a square?
A string is considered to be square if the following conditions are met:

Each line has the same number of characters
The number of characters on each line is equal to the number of lines.

Your task is to write a program or function which determines whether or not a given input string is a square.
You may require input to be delimited by your choice of LF, CR, or CRLF.
The newline character(s) are not considered part of the line's length.
You may require there to be or to not be a trailing newline in input, which doesn't count as an additional line.
Input is a string or 1D char array; it is not a list of strings.
You may assume input is non-empty and only contains printable ASCII, including spaces.
You must output a truthy value for square strings and a falsy one for other strings.
Truthy test cases:

foo
bar
baz

.

.s.
.ss
.s.
(s represents space)

ss
ss
(s represents space)

aaaaa
aaaaa
aaaaa
aaaaa
aaaaa

Falsy test cases:

..
.

.

.

....

....

4444
333
22

333
333

abc.def.ghi

Note extra blank lines in some of the falsy cases.
This is code-golf - fewest bytes wins!

Possible duplicate of Language Design: 2-D Pattern Matching. Problem #5 is the same as this question.

@mbomb007 I feel like the different winning criteria make this not a duplicate? "Golfiness" was one of the voting criteria but I don't think answers to that question will largely reflect on the ones here.

@mbomb007 I'm voting to leave this question open because, while it is a subset of the other question, the other question is restricted to languages created specifically for that question.

@mbomb007: That's not a duplicate, because that question asks you to design a language for the purpose of answering the question, rather than answering in an existing language. Very few of the answers here would be legal there.

The solutions there are legal here, however. Many of the answers have an exact solution to this challenge contained in them.

@mbomb007: That's no reason to close this challenge, and give people nowhere to post their answers in pre-existing languages, though. It might potentially be an argument for closing the other challenge (because it's just a more restrictive version of this one), although I'd consider it a poor argument and believe both should be left open.

Technically, the first requirement is redundant as it can never be false if the second is true.

Suggested test case: foo bar bazz (those three lines in that order) - my PCRE2 regex could be 4 bytes shorter and still match all the test cases, but would give false positives on shapes that are otherwise square but have a longer last line.

can i input as an array of strings?

Brachylog (2), 3 bytes
ṇẹṁ

Try it online!
Full program. Outputs true. for truthy, false. for falsey.
Explanation
ṇẹṁ
ṇ     Split {standard input} into lines
 ẹ    Split {each line} into basic elements {in this case, characters}
  ṁ   Assert that the result is square

I was a bit sceptical about the usefulness of the ṁ builtin when it was added, but I can't really deny that it's helpful here…
Brachylog (2), 7 bytes
ṇẹ.\l~l

Try it online!
Non-builtin solution. Still beats all the other entries, as of the time of writing. EDIT: Not quite, the equal-length Jelly entry got in while I was writing this, and beats it via the timestamp tiebreak.
Explanation
ṇẹ.\l~l
ṇ         Split {standard input} into lines
 ẹ        Split {each line} into basic elements {in this case, characters}
   \l     Assert that the result is rectangular, and the number of columns
  .  ~l     is equal to the number of rows

Correct tool for the job!

ṁ = "Assert that the result is square" :(

There was a challenge a while back where I was struggling to write an assert-square (it'd have been something like .\l~l at the time, except that the backslash command, which among other things asserts that its input is a rectangle, was broken; note that even if we replace ṁ with .\l~l, this is still the shortest program here; come to think of it, I'll add that to the post). The backslash command got fixed, but the language author decided to add an assert-square at the same time. I was thinking "surely that's never going to come up again". Apparently I was wrong.

What does the (2) signify?

@Phoenix: Version number of the language, this won't work in Brachylog v1. Most people just say "Brachylog" (just like most people say "Perl" rather than "Perl 5"), but I got into the habit a while back because I do use Brachylog v1 on rare occasions.

The 3 byte solution without the dots under and over the characters (nem) means no in Hungarian :D

@EriktheOutgolfer why is that problematic? Or do you just think it's a little boring?

@iFreilicht It's bad because it outgolfs every other golfing language so far.

Python 2, 52 bytes
x=input().split('\n')
print{len(x)}==set(map(len,x))

Try it online! or Try all test cases

I love the fact that this is both golfed and readable.

You do not need the '\n', just leave it empty (since there are no spaces and tabs in the input).

@12431234123412341234123 no, it does not work for square strings that contain spaces!!!

@Mr.Xcoder Must it work with spaces? As i understood there are never spaces in the input.

You misunderstood the specs: You may assume input is non-empty and only contains printable ASCII., and whitespace ( ) is printable ASCII

Why not just make a lambda like this?https://tio.run/##K6gsycjPM/5fYRvzPycxNyklUSHHqjonNU8jR7PW1rY4tUQjN7FAAyigk6Op@b@gKDOvRKNCI1opUUFJR0lBQSkWKAoA

@irapsaged OP didn't allowed Input is a string or 1D char array; it is not a list of strings.

Oh, sorry, my bad.

@irapsaged np c:

JavaScript (ES6), 46 45 bytes
s=>!(s=s.split`
`).some(x=>x.length-s.length)

1 byte saved thank to ETHproductions

Explanation

Split the string to an array on newlines.
Loop over the array.
Subtract the length of the array from the length of each line.
If a non-zero (i.e., truthy) value is returned for any line, the string is not square.
Negate the result of the loop to get true for square and false for not.

Try it

f=
s=>!(s=s.split`
`).some(x=>x.length-s.length)
oninput=_=>o.innerText=f(i.value)
o.innerText=f(i.value=`foo
bar
baz`)
<textarea id=i></textarea><pre id=o>

I think you can save a byte with s=>!(s=s.split`\n`).some(x=>x.length-s.length)

Thanks, @ETHproductions. I've a terrible habit of dismissing !some out of hand, simply because it's the same length as every.

Jelly, 7 5 bytes
Ỵ¬⁼Z$

Try it online!
Thanks to FryAmTheEggman for -2

05AB1E, 10 8 bytes
¶¡€gDgQP

Try it online!
-2 thanks to Riley, this is basically his answer ._.
Code       # Explanation                  | Truthy Example          | Falsy Example
-----------#------------------------------+-------------------------+--------------
¶¡         # Split on newlines            | [['aaa','aaa','aaa']]   | [['aa']]
  €g       # Get length of each           | [[3,3,3]]               | [[2]]
    D      # Dupe                         | [[3,3,3],[3,3,3]]       | [[2],[2]]
     g     # Get length                   | [[3,3,3],3]             | [[2],1]
      Q    # Check equality               | [[1,1,1]]               | [[0]]
       P   # Take product                 | 1                       | 0

@Riley ahhh, nice catch, my original idea was more along the lines of what you had but slightly different. Iterated two more times and didn't catch my math error.

I don't think "Header" is a valid form on input.

@Phoenix is that better?

Probably, IDK 05ab1e

Input can also be taken in with three quotes, like this.

If you get the length of each first you can avoid the s. Like this ¶¡€gDgQP

@Riley already got down to 8-bytes by changing the strategy entirely.

@carusocomputing I thought of that too, but it doesn't quite work

@Riley do you want the answer? This was basically all you after a certain point lmao. I feel bad still getting points for it.

@carusocomputing Nah, it's not that far from your original solution. I had enough fun working on it, I don't need the rep or anything.

Japt, 9 bytes
=Ur.Q)¥Uy

Test it online!
Explanation
 =Ur.Q)¥ Uy
U=Ur.Q)==Uy
             // Implicit: U = input string, Q = quotation mark
U=    )      // Set U to
  Ur.Q       //   U with each non-newline (/./g) replaced with a quotation mark.
       ==Uy  // Return U == U transposed. U is padded to a rectangle with spaces before
             // transposing; if U was not a rectangle before, or the sides are not of
             // equal length, the result will not be the same as U.
             // Implicit: output result of last expression

Using some features implemented shortly after this challenge was posted, this can be 6 bytes:
r.Q
¥y

Test it online!
Explanation
       // Implicit: U = input string
r.Q    // Replace each non-newline (/./g) in U with a quotation mark.
       // Newline: set U to the result.
¥      // Return U ==
 y     //   U transposed.
       // Implicit: output result of last expression

How in the world are you so fast?

@totallyhuman I happened to see the question the instant it was posted, and it took me two minutes to come up with an algorithm. After that it was just implementing and posting. (Also I have things to get back to haha)

Nice :) I knew y was the solution but mine was coming in at a few more bytes.

"Using some features implemented shortly after this challenge was posted" - You can now post that as your asnwer.

Jelly, 7 bytes
ỴµL;L€E

Try it online!
Explanation
Ỵµ       Split the input on newline and use as input in the second link
  L      Get the number of list items
   ;     And append to that
    L€   A list with the legth of each list item
      E  Check to see if all items are equal.

Your TIO link seems to indicate that no trailing newline should be there.

@Phoenix fixed / reverted...

This just checks to see if all lines are the same length - it actually doesn't take the newline count into account at all. When you reach the E atom, you have a list of line lengths and that's all.

@Christian fixed and shortened. Sorry 'bout the confusion, I guess something went wrong after I had a working solution and I tried to golf that..

Haskell, 38 34 bytes
l=length
(all=<<(.l).(==).l).lines

Try it online!
Pointfree version of f s = all ((==length (lines s)).length) (lines s), i.e split the input into lines and check if the length of each line is equal to the number of lines.
Edit: Thanks to @xnor for 4 bytes.

I think you can use all for map to cut the and..

Husk, 6 bytes
S≡T'a¶

Takes a string and prints either 1 or 0.
Try it online!
The first line iterates over the test cases; remove it if you want to test on a single value.
Explanation
Husk is a new functional golfing language created by myself and Leo.
It's missing a lot of features and development is ongoing.
Its main feature is a rigid type system that allows us to overload higher order functions.
On a high level, the program works like this:
S≡T'a¶  Define a function:
     ¶  split on newlines,
  T'a   transpose and pad to rectangle using character 'a',
 ≡      check if this has the same shape as
S       the split input.

The function ≡ actually checks if two arrays have the same shape and the same distribution of truthy elements.
In Husk, all characters except the null byte are truthy, and that won't occur in our inputs.
Also, S is the S-combinator, a function that takes as inputs two functions, here ≡ and T'a, and returns a new function that maps x to ≡(x)(T'a x).
The result of S is composed with ¶, and that function is applied to the input implicitly.
How does Husk know that it should apply S to the next function, but ¶ should be composed with the function on its left?
Simple: it just tries every interpretation and picks the one where the types make sense.
This is explained in more detail in the Husk documentation.

Retina, 33 31 bytes
.
.
^(.(.)*)(?<-2>¶\1)*$(?(2).)

Try it online! Explanation: The first stage simply changes all printable ASCII into the same character to make it easier to match. (It could be done without, but this is code golf, not code challenge.) The second stage then matches at least one character on the first line. However, for each additional character on the first line, it then optionally matches a newline followed by a copy of the first line. The final part of the expression causes the match to fail if there are more columns than rows.

Unfortunately, this outputs true for this testcase.

@KritixiLithos I believe the submission requires a trailing newline in input, which is allowed.

Also I believe using \S\n; instead of the first line saves one byte

@KritixiLithos Actually replacing . with . saves two, but thanks.

@Neil That's really clever!

Pure bash (no utilities), 55
mapfile -t a
for l in ${a[@]};{
((c+=${#l}^${#a[@]}))
}

mapfile reads the input into array a
then the number of elements of the array is XORed with each line length, and the sum taken.  For a perfect square, each XOR result (and thus the sum) will be 0.  For anything else, the result will be >0.

The opposite sense of this is returned as a shell return code (examine with echo $?) - perfect square is 1, anything else is 0.
Try it online (truthy).
Try it online (falsy).

Previous answer using eval-escape-expansion hell, 78:
mapfile -t a
echo $[0$(eval eval echo +\\$\{#a[{0..$[${#a[@]}-1]}]}^${#a[@]})]

Try it online (truthy).
Try it online (falsy).

Perl 6, 27 bytes
{.lines==all .lines».comb}

Tests whether the number of lines in the input string is equal to the number of characters on each line.

does this ignore the new-line character?

Yes, newlines are not returned by the .lines method.

Jelly, 4 bytes
Ỵ¬zƑ

Try it online!
Input via command-line argument. The input must be given with no trailing newline (otherwise the program sees a blank line at the end, which isn't the same length as the others); this I/O format is explicitly allowed by the question.
So far, the shortest answer that doesn't use an "is a square" builtin. (There's an existing 5-byte Jelly answer that works on similar principles, but is wrong, incorrectly considering "aa\na" to be square – this answer is not only shorter, it also fixes that issue.)
Explanation
Ỵ¬zƑ
Ỵ      split {the input} on newlines
 ¬     replace every truthy character (i.e. all of them) with 0
   Ƒ   does that remain unchanged, after
  z      a ragged transpose that pads to a rectangle using {the input}?

There are two main cases:

The string is not even a rectangle. In this case, the "transpose and pad to rectangle" builtin z will pad the string to a rectangle, but uses copies of the user input as the padding, which are not zeroes (even if the input uses the character '0', this compares unequal to the integer 0). So there's no way the ragged transpose can leave the split-and-zeroed version of the input unchanged.
The string is a rectangle. In this case, the ragged transpose won't apply any padding, but will produce a rectangle of zeroes with the number of rows and columns swapped from the transpose input. The only way the input and output can match is therefore if the number of rows equals the number of columns, i.e. the input is a square. (If the input is a square, the transpose will leave it unchanged because, as every element is a zero, all the elements will be the same and thus it doesn't matter that the transpose swaps some of them.)

Pyth, 7 bytes
CImL1.z

Try it here
Requires no trailing newline. Replaces the input with a 2D array of 1s where a 1 represents any character in the original input. Then we check whether that array is unchanged after transposing it (replacing columns with rows). Only a square will return true in such a situation.

Java (OpenJDK 8), 96 91 90 87 bytes
-5 bytes thanks to @KevinCruijssen
-1 byte thanks to @TheLethalCoder
-2 bytes thanks to @OlivierGrégoire
a->java.util.Arrays.stream(a.split("\n")).allMatch(x->x.length()==a.split("\n").length)

Try it online!

@Phoenix Fixed, thank you! :-)

You can remove the space at String[]s and you can remove the ,0 in the .split("\\n"); for -3 bytes. And the semicolon/; at the very end you won't have to count, so that another -1. Oh, and you have to include the java.util. in front of the Arrays I'm afraid. Imports/usings are part of the byte-count as well.

Since you forgot to include the java.util., just a regular for-loop like this for(String x:s)if(x.length()!=s.length)return 0>1;return 1>0; seems to be shorter than return java.util.Arrays.stream(s).anyMatch(l->l.length()!=s.length);.

@KevinCruijssen Thanks for saving me several bytes! :-)

Is it not just \n?

@TheLethalCoder String.split() takes a String (a regex) and, optionally, an int (a delimiter) as parameters. Therefore, I thought the backslash had to be escaped. But at the end of the day it worked without escaping, so thanks for saving me 1 byte! :-)

Repeating the a.split("\n") is actually shorter! a->java.util.Arrays.stream(a.split("\n")).allMatch(x->x.length()==a.split("\n").length)

@OlivierGrégoire In fact it is 1 char shorter, but for some reason TIO says it is [91 chars, 99 bytes] long (compared to the [90 chars, 90 bytes] of my current answer).

Well, it's totally explainable: Stackoverflow add some blank empty unicode characters to cut the long  code blocks. This way, the comments aren't taking too much space. It happens quite a lot on this website because of its nature. By the way, I counted 87 chars, not 89 (or 91), and I just double-checked again: 87 chars, not any single more. If you count manually or retype it exactly as is, you'll see that. In this case, the extra characters are between the last . and the last length.

Hmmm... some more are present as well between leng and th(). So apparently, they appear first after the 60th char then every 20 characters.

@OlivierGrégoire I suspected that from the beginning. It makes sense. I re-typed everything on my IDE, pasted on TIO and voilà: 87 bytes! Thank you :-)

MATL, 14 12 bytes
10H&XXot&n=h

The input string is defined using string concatenation ([...]) and with the code point 10 to represent LF. For example, ['aaa' 10 'bb'] is interpreted in MATL as string 'aaa' concatenated with the character with code point 10 concatenated with string 'bb'.
The output is a non-empty numeric vector, which is truthy if and only if all its entries are non-zero.
Try it online!
Explanation
Consider input ['4444' 10 '333' 10 '22'].
10H   % Push 10 (code point of LF). Push 2
      % STACK: 10, 2
&XX   % Regexp with three arguments. First argument is implicit input (string);
      % second is 2, which indicates that we want to split the input; third is
      % 10, which is the character to split on. The result is a cell array of
      % matched strings
      % STACK: {'4444', '333', '22'}
o     % Concatenate into a numeric 2D array of code points, right-padding with
      % zeros if needed
      % STACK: [52 52 52 52; 51 51 51 0; 50 50 0 0]
t&n   % Duplicate. Push number of rows and number of columns
      % STACK: [52 52 52 52; 51 51 51 0; 50 50 0 0], 3, 4
=     % Are they equal?
      % STACK: [52 52 52 52; 51 51 51 0; 50 50 0 0], 0
h     % Concatenate into a row vector (in column-major order). Implicit display
      % STACK: [52 51 50 52 51 50 52 51 0 52 0 0 0]

05AB1E, 7 bytes
|€gDgQP

Try it online!

Kind of cheating imo, that's basically taking n inputs instead of 1 and why my original answer didn't work.

@carusocomputing No, | means "take the rest of the input and split by newlines" which is in no way taking multiple inputs. You just have to treat STDIN as a single input.

R, 57 bytes
function(s)all(nchar(n<-strsplit(s,'
')[[1]])==length(n))

An anonymous function; Splits on newlines, computes the length of each line, and checks if all are the same as the number of lines.
Try it online!

Ruby, 50 bytes
s=$<.read.split $/,-1;p [s.size]==s.map(&:size)|[]

Try it online!
Explanation

Split input into array on newline.
Assert that an array containing only the size of this array is equal to an array containing all uniq (set union with empty array) sizes of all elements in this array.

Save a character with  .split($/,-1); -> .split $/,-1;

Save more by using lines instead of read and then split (but then you have to add 1 to size because the lines include the trailing newline)

45 bytes: Try it online!

R, 35 bytes
all(nchar(x<-scan(,""))==length(x))

Takes input from stdin. Checks that the number of characters in each line is equal to the total number of lines. Returns TRUE or FALSE as appropriate.

note that inputs need to be wrapped in quotes or this might break on spaces within each line.

JavaScript (ES6), 48 bytes
s=>(a=s.split`
`,a.every(l=>l.length==a.length))

CJam, 11 bytes
qN/:,_,f=:*

Try it online!

Pyth, 12 10 bytes
!fnl.zlT.z

Saved 2 bytes thanks to @FryAmTheEggman.
Try it online
Explanation
!fnl.zlT.z
 f     T.z     Filter lines of the input
  nl.zl        whose length is not the number of lines
!              and return whether there are no such lines.

OCaml, 56 bytes
let f t=List.(for_all(fun l->String.length l=length t)t)

Try it online!

QBIC, 43 bytes
{_?~_lA||h=h+1┘g=g+_lA|~g%_lA||_Xp]\_xg/h=h

Me, I'm happy with how short a QBasic derivative got to go on this challenge.
Explanation:
{_?       DO infinitely: ask the user for input, store as A$
~    |    IF
 _lA|       The length of A$   (implicitly <> 0)
h=h+1     Add 1 to our line counter
┘         (syntactic linebreak)
g=g+_lA|  Add the length of this line to the running total of line lengths
~      |  IF
 g%_lA|     The length of the running total modulo the length of the last string
            yields anything but 0, there is a discrepancy between earlier line
            lengths and this one.
_Xp]      THEN QUIT, printing 0, end IF
\         ELSE (refers to the LEN(A$), user didn't input anything.
_xg/h=h   QUIT (the inf. loop) printing -1 if the root of the chars is the row count
            or 0 if not.

Pyth, 7 bytes
qCC.z.z

Demonstration
Transpose the input with truncation twice, then check if the result is the same as the original.

Perl 5, 31 bytes
29 bytes of code + -p0 flags.
/.*/;$_=/^(.{@{+}}
){@{+}}\z/

Try it online!
Explanations:
/.*/ matches the first line, and thus makes @+ contain the length of the first line. Then the regex checks whether the string contains @+ lines of length @+.

MacOS Bash, 34
rs -EH|awk '{print $1}'|uniq|wc -l

rs is part of the default MacOS image.  This will also work on Linux if rs is installed; it is on TIO.

rs -EH lists the length of each line, along with the number of lines
awk strips out extraneous info
uniq outputs one line if the line lengths and number of lines are all the same, but more otherwise
wc -l outputs 1 if the input is square or a greater number otherwise.

Try it online: Truthy, Falsey.

AWK, 49 bytes
{s=length($0)}L{x+=L!=s}{L=s}END{print x?0:L==NR}

Try it online!
Could also have used a BEGIN block to set FS="" but that would be the same byte-count. For some reason using the -F"" argument never seems to work.

Stax, 9 bytes
éΘ┌«■/ÉW(

Run and debug online!
Turns out that due to way pairwise difference is calculated, I don't need to worry about the equivalence of k and x-k here. Saving 5 bytes.
Uses the unpacked version to explain.
Lc{%mc%+:u
L             Collect rows in a list
 c{%m         List of length of each row
     c%+      Append number of rows to the list
        :u    All elements in the list are equal

PowerShell, 48 bytes
($a=$args-split'
'|%{$_.Length}).Count-eq($a|gu)

Test script:
$f = {

($a=$args-split'
'|%{$_.Length}).Count-eq($a|gu)

}

@(

,($true,@"
foo
bar
baz
"@)

,($true,@"
.
"@)

,($true,@"
. .
.
. .
"@)

,($true,@"

"@)

,($true,@"
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
"@)

,($false,@"
..
.
"@)

,($false,@"
.

"@)

,($false,@"

.
"@)

,($false,@"
....

....
"@)

,($false,@"
4444
333
22
"@)

,($false,@"
333
333
"@)

,($false,@"
abc.def.ghi
"@)

) | % {
    $expected,$s = $_
    $result = &$f $s
    "$($result-eq$expected): $result"
}

Output:
True: True
True: True
True: True
True: True
True: True
True: False
True: False
True: False
True: False
True: False
True: False
True: False

Explanation:

$args-split"``n"|%{$_.Length} creates an array of length of each line.
$a.Count counts elements of the array
$a|gu apply Get-Unique to the array. The result is one integer element if all lines has same length.
$a.Count-eq($a|gu) compares Count of element with result of the Get-Unique. It's true if all lines has same length and this length equals to Count.

Pip, 11 bytes
Y0MMa^ny=Zy

Takes a multiline string (with no trailing newline) as a command-line argument. Try It Online!
Explanation
Y0MMa^ny=Zy
    a        Command-line argument
     ^n      Split on newlines
  MM         To each character of each line, map:
 0           0
             This results in a nested list of 0's, one for each character
Y            Yank it into the y variable
       y=    That nested list equals
         Zy  Its transpose

For example, with inputs "abc\ndefg" and "ab\ncd":
    a^n      ["abc";"defg"]       ["ab";"cd"]
Y0MM         [[0;0;0];[0;0;0;0]]  [[0;0];[0;0]]
         Zy  [[0;0];[0;0];[0;0]]  [[0;0];[0;0]]
       y=    0                    1

This gives a false negative when spaces are in certain places, including a square made entirely of spaces (test case #4) and any square with spaces only in its last line.

@Deadcode Input containing spaces needs to be wrapped in quotes. I updated the DSO link to reflect that.

Vyxal, 5 bytes
¶o²⁋=

Try it Online!
¶o²⁋=
¶o    # Remove all newlines
  ²   # Format as a square
   ⁋  # Join by newlines
    = # Equal to the input?

Regex (.NET), 55 bytes
^.((.))*(?<-1>
.(?=(?<-2>.)*(?(2).)
)(?<2>.)*)*$(?(1).)

Try it on regex101
Neil said in his Retina answer, "It could be done without, but this is code golf, not code challenge." Well, here's a pure regex answer that needs to do it that way (without substitutions done beforehand to lighten the load).
The last line must end with exactly one newline. To remove this restriction would result in worse golf.
In this explanation, ¶ indicates a raw newline in the regex:
^                    # Anchor to start of string
.                    # Skip one character, due to the fact that when we count
                     # the number of rows, matching it up with our capture count,
                     # the first row won't becounted.
((.))*               # Add the remaining length of this line to the capture count
                     # of both \1 and \2.
(?<-1>               # If there is at least one capture on the \1 stack, do the
                     # following:
    ¶                # Advance to the next line (thus proving that the entire
                     # previous line was processed)
    .                # Advance by one character (because we already did the same
                     # on the first line)
    (?=              # Lookahead - allows the same part of the string to be
                     # matched in multiple ways.
        (?<-2>.)*    # For each capture remaining on the \2 stack, advance one
                     # character. Will stop short if it reaches the end of the
                     # line before the \2 stack is emptied.
        (?(2).)¶     # Assert that if the \2 stack is not empty, there is at
                     # least one more character remaining in this line, but also
                     # assert that this is the end of the line - effectively
                     # asserting that the \2 stack is empty and we're at the end
                     # of the line.
    )
    (?<2>.)*         # Having already proved that this line is of equal length to
                     # the previous, transfer its length back into the capture
                     # count of group \2.
)*                   # Iterate the above as many times as possible, minimum zero.
$                    # Assert that we've reached the end of the string, or a
                     # newline after which it is the end of the string.
(?(1).)              # Effectively assert that the \1 stack is empty, as it is
                     # impossible to match one more non-newline character after
                     # reaching the end of the string.

Regex (Perl / PCRE2), 69 64 bytes
^(?=((?|
()|.(?=.*
(\2?+.)))+)+
\2$)((?=^|.+(\4?+
.+)).)+\4$|^.$

Try it online! - Perl
Try it on regex101 - PCRE2
A trailing newline on the last line is optional. Squares with or without it will both match. (In the 69 byte version, the trailing newline was mandatory.)
In PCRE, acceptance of a trailing newline can be disabled with a flag: Try it on regex101
But in Perl, the only way to do this is to replace $ with \z (+1 byte): Try it online!
The regex does not work in PCRE1 (the older and no longer maintained version of PCRE) due to a PCRE1 bug in which \2, a nested backreference, is not reverted to its earlier value when backtracking, causing it to have false positives on shapes that have an equal number of lines as characters in their first line, but whose remaining lines monotonically increase (or stay the same) in length.
In this explanation, ¶ indicates a raw newline in the regex:
^                          # Anchor to start of string
(?=                        # Lookahead - allows the same part of the string to
                           # be matched in multiple ways.
    # Assert this is a rectangle (all lines have an equal number of characters)
    # with at least 2 lines. A trailing newline on the last line is optional.
    (
        (?|                # Branch Reset Group - allows the same group numbers
                           # to be captured in different parts of the regex.
            # This alternative is to be taken when the inner loop has reached
            # the end of a line, finishing this iteration of the outer loop.
            ¶
            ()             # \2 = empty, in preparation for the next iteration
                           #      of the outer loop
        |
            # This alternative is to be taken while still processing the line.
            .              # Go forward one character.
            (?=            # Lookahead - match what's inside, then jump back to
                           # this position upon exiting it.
                .*¶        # Skip to the next line
                (          # \2 = the following:
                    \2?+   # Match previous value of \2 if set
                    .      # Match one extra character in this line
                )
            )
        )+                 # Iterate the above as many times as possible
    )+                     # Iterate the above as many times as possible
    ¶                      # Match a newline. Note that the regex engine will
                           # be forced to backtrack, because it will have
                           # already matched this newline inside the loop, and
                           # erased the contents of \2. Backtracking allows it
                           # to undo this, restoring the contents of \2 and
                           # allowing us to match the newline and \2 here.
    \2$                    # Assert that the last line is not longer than the
                           # penultimate line, by asserting that the string
                           # ends after the \2 that was captured. Note that "$"
                           # will match whether this is the end of the string,
                           # or a newline followed by the end of the string.
                           # "\z" only matches at the exact end of the string,
                           # but we don't need to use it.
)
# Assert the number of characters in the first line equals the number of lines
(
    (?=                    # Lookahead
        ^                  # On the leftmost character, match nothing else.
    |                      # On all subsequent characters, do the following:
        .+                 # Skip to the end of this line
        (                  # \4 = the following:
            \4?+           # Match previous value of \4 if set
            ¶.+            # Match a newline, followed by one more entire line,
                           # which we assert is at least one character long.
        )
    )
    .                      # Go forward one character.
)+                         # Iterate the above as many times as possible
\4$                        # Assert that the string ends after \4.

|^.$                       # Or, match a 1×1 square, which the above code can't
                           # do. Again, a trailing newline is optional due to
                           # the behavior of "$".

For my own edification, these regex engines are not "pure" DFA's, and a true regular language (in the computer science sense) couldn't solve this problem -- is that accurate?

@Jonah That is correct. Lookaheads together with backreferences extend it beyond being a true regular language.

Scala, 42 39 bytes
Fairly compact, yet easily understandable
Saved 3 bytes thanks to @Steffan.
39 bytes solution using Java 8 Try it online!
s=>s.lines.forall(_.size==s.lines.size)

42 bytes solution using Java 11 or newer Try it online!
s=>s.lines.allMatch(_.size==s.lines.count)

By our meta consensus, you can't take input from a variable. You could instead use an anonymous function and prepend s->, though.

noted, thank you @Steffan

Here's an ATO link for testing this code: Try it online!

Also, this only works in Scala 2 for me, because lines returns an Iterator instead of a Stream in Scala 3. You can save 3 bytes by using Scala 3, though: Try it online!

This is interesting. Its not Scala but Java version that is causing the issue, it is the same reason for your shorter solution to be possible.
Scala uses Java types and strings are no exception but they are implicitly converted to StringOps class which provides richer API.
Scala first introduced StringOps.lines (returns Iterator) , however Java 11 added String.lines (returns Stream).
forall is available only if you use Iterator. lines will implicitly return Iterator only if Java version < 11.
@Steffan tio uses Scala 2.10.6, Java 8, ato uses Scala 2.13.8, Java 18

Ah ok, that's interesting. Fsr I thought TIO ran Scala 3. ATO has Scala 3, but it's broken, unfortunately

Julia 1.0, 42 bytes
!x=(y=split(x,"
");~=length;all(~y.==.~y))

Try it online!
This function splits the string over newlines and checks if the number of lines is equal to the length of each line. Since length must be called twice (vectorized and non-vectorized), it is renamed as ~ (Thanks amelies!).

Not sure this answers the topic question

@amelies You're right, thanks! I pasted in the solution to a different question by mistake.

No problems! You can save one byte by replacing \n with a CR

Renaming length you can get to 40 bytes. Very good solution, I doubt I can golf more mine to beat this!

Cheddar, 39 bytes
@.split("
").all((i,j,k)->i.len==k.len)

Try it online!

Clojure, 58 bytes
#(let[s(re-seq #"[^\n]+"%)c count](apply =(c s)(map c s)))

Requires a trailing newline, looking forward to seeing something more magical.

APL (Dyalog), 17 bytes
Requires ⎕ML←3 which is default on many systems. Uses CR.
↓∘⎕FMT≡⎕TC[2]∘≠⊂⊢

Try it online!
↓∘⎕FMT [is the] split-into-lines Formatted-into-a-square argument
≡ identical to
⎕TC[2]∘≠ the into-groups-of-non-newline*-characters
⊂ partitioned
⊢ argument?
* the second element of the list of Terminal Control characters.

In version 16.0, one can write ↓∘⎕FMT≡⎕TC[3]∘≠⊆⊢ with ⎕ML←1.

Curious, what's ⎕ML?

@Phoenix In Dyalog APL and APL+, Migration Level is a rough measure for the dialectical movement in direction of IBM's APL2. The higher the number, the more APL2-like does the language become. People migrating from APL2 to other APLs tend to run with a high ⎕ML, while people who started with the other APLs tend to run with a low ⎕ML.

PowerShell, 64 bytes
The same (split, line lengths, number of lines) approach as other non-golf language answers, but there's no nice map() equivalent, so it's an array of line lengths with the number of lines tagged onto the end, then that array is grouped. Squares come out like 3,3,3,3 -> 1 group, all line lengths and line count were equal and non-squares come out like 3,2,1 -> 3 groups, something was unequal in the square:
$f={@(@(($L="$args"-split"`n")|% le*)+$L.Count|group).Count-eq1}

Requires newline Linux-style endings, no trailing newline. e.g.
$Ttests = @(@'
foo
bar
baz
'@,
'.',
@'
aaaaa
aaaaa
aaaaa
aaaaa
aaaaa
'@
)
$Ttests = $Ttests | foreach {$_ -replace "`r"}

$Ttests | % { & $f $_ }

(And you can do similar for the false tests, but I won't put it here as there's more of them). The couple of @ symbols are required for when the input is the single '.' otherwise splitting it doesn't make an array of one string it just makes one string, and then the array concatenation doesn't output 1,1 it outputs 2.
I hoped it might be shorter to replace all the characters with 'a', and then brute force from 1 to Input Length all the squares 'a' and see if any matched the input. Once I got past param() and .Length and -join and -replace it ends up much longer at 81 bytes:
$f={param($s)!!(1..$s.Length|?{,('a'*$_)*$_-join"`n"-eq($s-replace"[^`n]",'a')})}

Grime, 11 bytes
e`.|_./+/.+

Prints 1 for squares and 0 for non-squares.
Try it online!
Explanation
A detailed explanation can be found on the Grime tutorial page, which happens to contain this exact program as an example.
e`.|_./+/.+
e`            Match entire input against pattern:
  .           A single character
   |          OR
    _         a recursive match of this pattern
     ./+      with one column of characters on its right
        /     and below that
         .+   one row of characters.

C#, 73 bytes
using System.Linq;s=>s.Split('\n').All(l=>l.Length==s.Split('\n').Length)

Explanation:
using System.Linq;    //Import Linq
s=>                   //Take input
s.Split('\n')         //Split the input stirng by line feeds
.All(l=>              //Make sure All lines in the array return true for:
l.Length              //The length of the line
==                    //Equaling
s.Split('\n').Length) //The length of the array split again by line feeds

Dart - 54 chars
q(s)=>!(s=s.split('\n')).any((x)=>x.length!=s.length);

(Expects input separated by newlines and not terminated by one)
Try it online

Clojure, 42 chars
#(every?(fn[x](=(count %)x))(map count %))

><>, 76 bytes
This should work, next step is trying to golf it more!
0v      0   <
 >i:0)?!va=?^1+
:0)?v1n;\~l:   >
    >r:@=?!vr1-^
        ;n0<

Try it online! Or more more fun, try some examples using this animated interpreter.
printf "aaa\naas\naaa" | fish _square.fish --tick 0.1 --play

Explanation
The idea is roughly as follows.

Fill the stack with the number of characters on each line.
Push the length of the stack, corresponding to the number of lines (n).
Do n times:

Check if bottom two elements are equal.
Remove deepest element.

Examples
For
aaa
aaa
aaa

we get [3, 3, 3, 3] after the first two steps and we can see that all three length 2 subsequences are equal. However, for
aaa
aa
a

we get [3, 2, 1, 3] and not all sequences are equal. For the last falsy case
`abc.def.ghi`

we get [11, 1] so there is only subpair we can check, but it is unequal so we return falsy.

Charcoal, 20 bytes
Ａ⁺№θ¶¹αＦ⪪θ¶Ａ×α⁼αＬιαα

Try it online! Prints - repeated by the side length as truthy, nothing as falsy.

PHP, 65 bytes
while(~$c=$argv[1][$p++])$w+=":"^$c||$w=!$$w+=!!++$h;echo$$h==$h;

expects linux style line endings (\n) and a trailing newline; prints 1 for truthy, nothing for falsy.
Run with php -nr '<code>' '<input>' or try it online.

Btw: The naive approach takes 82 bytes:
<?=count($a=explode("
",$argv[1]))==min($m=array_map(strlen,$a))&min($m)==max($m);

expects linebreaks as on compile system and no trailing newline; prints 1 or 0.
Run with php -nR '<code>' '<input>'.

Python 3, 79 bytes
lambda a:len(set([len(list(i))for i in a.split('\n')]+[len(a.split('\n'))]))==1

Add++, 45 bytes
D,g,@,bU10C€=sVcG1+V10CAtbU€bLB]db=$bM*G=

Try it online!
How it works
Boy this was a long one (not even counting the footer)
D,g,@,		; Declare a monadic function 'g'
		; Example argument:    		 ['foo\nbar\nbaz']
	bU	; Unpack;		 STACK = ['f' 'o' 'o' '\n' 'b' 'a' 'r' '\n' 'b' 'a' 'z']
	10C€=s	; Count newlines;	 STACK = ['f' 'o' 'o' '\n' 'b' 'a' 'r' '\n' 'b' 'a' 'z' 2]
	VcG	; Keep last value;	 STACK = [2]
	1+V	; Increment and save;	 STACK = []			; STORE = 3
	10CAt	; Split arg on newlines; STACK = [['foo' 'bar' 'baz']]
	bU€bLB]	; Length of €ach;	 STACK = [[3 3 3]]
	db=	; Are they all equal?	 STACK = [[3 3 3] 1]
	$bM	; Max value;		 STACK = [1 3]
	*	; Logical AND;		 STACK = [3]
	G=	; Equals STORE?		 STACK = [1]

Try it online!

Swift 3, 134 bytes
import Foundation;func r(s:String)->Bool{let i=s.components(separatedBy:"\n");return i.filter{$0.characters.count != i.count}.isEmpty}

Try it online!

Wren, 76 61 bytes
Fn.new{|a|a.split("\n").all{|x|x.count==a.split("\n").count}}

Try it online!
Old answer
The algorithm is essentially just copied from a 05AB1E answer.
Fn.new{|a|
var b=a.split("\n").map{|i|i.count}
return b.all{|i|i==b.count}
}

Try it online!

Red, 73 bytes
func[s][all collect[foreach b a: split s lf[keep(length? b)= length? a]]]

Try it online!
{abcd
efg}  represents true multiline string and not a list of strings, hence I need split s lf

Google Sheets, 47
Closing parens/quotes already discounted.
Input: A1
A2 to A3:
=ArrayFormula(LEN(SPLIT(A1,"
")))
=A2=COUNTIF(2:2,A2)

SnakeEx, 38 bytes
h:{c<B>1}{c<L>1}{e<>}{e<R>}
c:.+$
e:.$

A match is truthy; no match is falsey. Try it here

The previous 50-byte SnakeEx submission was copied from the original solution to the detect-square-inputs problem in the 2D pattern-matching language challenge. Here's the thing: that problem says, "Match the entire input if it is a square block of characters." But for this problem, we merely need to match something if the input is a square block of characters. That enables us to use a different approach, saving bytes.
Instead of matching the whole square, we match its bottom row and rightmost column and assert that they are the same length. (It's important to pick the rightmost column, since that will fail if we have jagged input.)

c:.+$ Define c to match some number of characters and then the edge of the grid
e:.$ Define e to match the character it's currently on and then the edge of the grid
{c<B>1} Turn backwards (i.e. toward the left side), match c, and put that match in group 1
{c<L>1} Turn left (i.e. toward the top), match c, and put that match in group 1 (thereby requiring both matches to be the same length)
{e<>} Match e in the default direction (toward the right side)
{e<R>} Turn right (i.e. toward the bottom) and match e

The two c calls make sure the height and width are the same; the two e calls make sure our starting point is the bottom right corner.

05AB1E, 7 bytes
.B¤g∍»Q

Try it online or verify all test cases.
Explanation:
.B       # Box the (implicit) multi-line input-string, splitting on newlines,
         # and appended spaces to make all rows the same length
  ¤      # Push the last string (without popping the list)
   g     # † Pop and push its length
    ∍    # Extend/shorten the list up to this length
     »   # Join it by newlines
      Q  # Check if it's equal to the (implicit) input
         # (after which the result is output implicitly)

† This is only necessary if the last line of the input is a number. Builtin ∍ will extend/shorten it to the number size if a number is given as argument, but will use the length to extend/shorten if a string is given. E.g. "ab" "abcdefg" ∍ will extend the "ab" to length("abcdefg")=7, resulting in "abababa", but unfortunately "123" "12" ∍ will extend the "123" to "123123123123" instead of shortening it to length("12")=2 to "12".
So for all given test cases .B¤∍»Q would have sufficed, but unfortunately it'll fail for something like 123\nabc\n7.3.

BQN, 15 bytes
>∘⊔'
'⊸(≠×1+`=)

Anonymous tacit function. Takes a multiline string that must include a trailing newline. Try it at BQN online!
Outputs via error for falsey and no error for truthy. If that's not acceptable, here's a 19-byte version that returns 0 for falsey and 1 for truthy:
≡·>⎊0·⊔'
'⊸(≠×1+`=)

Explanation
>∘⊔'¶'⊸(≠×1+`=)
       (      )   Call this function with the multiline string as right argument
   '¶'⊸           and a newline character as left argument:
             =      For each character in the string, 1 if it is newline, 0 otherwise
           +`       Cumulative sum of that array
          1         starting at 1
         ×          For each of those values, multiply by the corresponding value in:
        ≠           For each character in the string, 0 if it is newline, 1 otherwise
                  This transforms the first line into 1s, the second line into 2s, etc.,
                  and newlines into 0s
  ⊔               Group the indices of this list according to their values in the list
>∘                Attempt to convert that list of lists to a rectangular array

If not all lines in the input are the same length, the groups will have different lengths, and the conversion to an array will fail.
If the input is rectangular but not square, the newlines group will have a different length from the other groups, and the conversion will fail.
If the input is an N by N square, there will be a group representing N newlines and N groups representing N characters each, which will be successfully converted into an N+1 by N array.

APL, 10 or 8 bytes
(≢=(⌈/≢¨))

Input is an array of strings.
Explained:
(       ) fork (could be removed if assigned to a variable)
 ≢        amount of strings
  =       equals
   (⌈/ )  the maximum
     ≢¨   of each of the string's lengths

"Input is a string or 1D char array; it is not a list of strings."

But that's the closest i can get, i don't how to type new line.

Julia 1.0, 44 41 bytes
!s=(l=count(==('
'),s)+1)l==length(s)-l+1

Try it online!

SnakeEx, 50 bytes
This is BMac's solution to the problem for the 2D regex language design challenge.
m:{v<R>1}{h<>1}
v:${c<L>A1}+$
h:${c<R>A1}+$
c:$.+$

Try it online

J, 12 bytes
(*./=#)#;._2

Input requires trailing LF or CR.
Explanation:

;._2 split into intervals and discard trailing atom
# count each group
(*./=#) is a fork which returns 0 (false) or 1 (true) if the LCM of the count of each group is equal to the count-of-counts

Tests
(*./=#)#;._2 'abc', LF, 'def', LF, 'ghi', LF   NB. 1 for well-formed input
(*./=#)#;._2 'abc', LF, 'def', LF, 'ghi'       NB. 0 because no trailing LF

How does it determine what the delimiter is..? And by the way, abc.def.ghi. should be falsy, so while clever, the delimiter trick is actually invalid.

@Phoenix A test case to reflect that would be beneficial

@Phoenix My answer used to just say "requires trailing delimiter" but I edited it to specifically call out either LF or CR.
abc.def.ghi. would be truthy but abc.def.ghi.LF (trailing LF) would be falsy.

abc.def.ghi. Is not a square string and should not be accepted.

The way I read the rules, since I can require that all inputs end in LF, then my program should never have the chance to either accept or reject inputs which don't end in LF.

15 Bytes for */(=#)#@>@cutLF, which only accepts LF as a delimiter, and does not require a trailing LF: */(=#)#@>@cutLF 'abc', LF, 'def', LF, 'ghi' returns 1

This fails by returning true if the row counts are, eg, 4 2 4 4.  Try it online!.  The function [:(-:{.#{.)#;._2 works.

Burlesque, 7 bytes
ln)L[sm

Try it online!
Requires a trailing newline after the input. Technically the trailing newline is only needed if the input ends on a newline (as ln ignores one trailing newline), and it doesn't make a difference whether it's there or not otherwise, but stating it as a blanket requirement is probably preferable. Returns 1 for square inputs and 0 otherwise.
Explanation:
ln       # Split input string into lines
  )      # Map each line...
   L[    # ...to its length
     sm  # Are all line lengths the same?

This is checking that the input is a rectangle, but not that it is a square. You need to also check that the length of a line is the same as the number of lines.

Factor + math.matrices, 28 bytes
[ "\n"split square-matrix? ]

Try it online!

Zsh, 40 bytes
set -- "${(@f)1}"
for l;(($#l==$#))||bye

Try it online!

Using modern decision-problem rules, we can save 1 byte by swapping truthy and falsy:
Zsh, 39 bytes
set -- "${(@f)1}"
for l;(($#l-$#))&&bye

Try it online!
set -- "${(@f)1}"    # (f) splits into lines, (@) and "" are needed to preserve empty lines
for l                # for each line:
   (($#l-$#))&&bye   # - if the line length differs from the number of lines, exit 0.
                     # otherwise, ((0)) from the last loop iteration has an exit code of 1,
                     # so we exit 1.


text:
I <3 conditionals
You end up having a lot of very long, boring-looking conditionals in your code:
if flag == 1:

while have != needed:

if type == 7:

These can be transformed into their much more lovable <3 conditionals counterparts:
if abs(flag - 1) + 2 <3:

while 3 - abs(have - needed) <3:

if 2 + abs(type - 7) <3:

Task
Your task is to take a conditional and make it in terms of <3. The only spacing that matters is that there is none between < and 3.
Conditionals will be two expressions seperated by either ==, !=, >, <, >= or <=.
Expressions will only contain addition, subtraction, unary negation (-something), where there is one + or - before each variables or numbers (except the first which has nothing or - before it).
Numbers will be [0-9]+, and variables will be [a-z]+. If the answer needs to use |x| (The absolute value of x), use the abs() function. You may assume that all variables are integers, and all number constants in the input are < 1000.
The output does not need to be in it's simplest form. It does need to be a conditional like above, meaning that it is two expressions only, seperated by one conditional sign, but it can also use the abs function, enclosing a valid expression, and then it acts like a variable, in terms of validity.
If the input does not have an output for any value of a variable, output a condition that is always false, but still in terms of <3.
Part of the challenge is figuring out how to do it, but here are the steps for the have != needed above:
have != needed
have - needed != 0
abs(have - needed) > 0
-abs(have - needed) < 0
3 - abs(have - needed) <3

Scoring
This is code-golf, so the shortest valid code, in bytes, wins.
Test cases
(Note, these outputs aren't the only outputs, but I tried to simplify them.)
flag == 1
abs(flag - 1) + 2 <3

have != needed
3 - abs(have - needed) <3

type == 7
2 + abs(type - 7) <3

x > y
3 - x + y <3

x + 5 < -y
x + 8 + y <3

x + 6 <= y
x + 8 - y <3

-x >= y + 3
x + y + 5 <3

x < x
3 <3
# Unsimplified; both would be valid outputs.
x - x + 3 <3

Is there always exactly one space between input tokens?

@Doorknob No. There will be 0 or 1 spaces.

Retina, 95 bytes
<=
<1+
>=
>-1+
(.*)(.=)(.*)
$2abs($1-($3))
==
2+
!=
3-
(.*)>(.*)
$2<$1
(.*)<(.*)
$1-($2)+3
$
<3

Try it online!
A rather naïve solution, but I haven't been able to find any improvements.
This is just a series of replacements:
<=
<1+
>=
>-1+

Get rid of "or equal to" comparisons by replacing x <= y with x < 1 + y, and x >= y with x > -1 + y.
(.*)(.=)(.*)
$2abs($1-($3))

Replace x == y with ==abs(x - y), and x != y with !=abs(x - y).
==
2+
!=
3-

Replace == with 2+ and != with 3-, so that the overall replacements become x == y → 2 + abs(x - y) and x != y → 3 - abs(x - y).
(.*)>(.*)
$2<$1

Normalize the direction of the remaining inequalities, replacing x > y with y < x.
(.*)<(.*)
$1-($2)+3

Replace x < y with x - y + 3.
$
<3

Append a heart to the end of the string.

source: Stack Exchange

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/

sort: votes


text:
How good am I at CS:GO?
Your task is given an input string of the full/short name of a CS:GO (Counter-Strike: Global Offensive, a computer game) rank return an integer from 1-18 representing the rank number. A higher number means you are a higher rank and so "better" at CS:GO.
Input
A string representing either the full name or short name of the CS:GO rank. Your code must be able to handle both cases.
Output
An integer representing the rank number of the given input. You can output in either 0-indexing or 1-indexing as 0-17 and 1-18 respectively.
Test cases:
The test cases use 1 - 18 as the output, just subtract one if you are using 0-indexing. Where SN means short name.
Full name                     SN   -> output

Silver I                      S1   -> 1
Silver II                     S2   -> 2
Silver III                    S3   -> 3
Silver IV                     S4   -> 4
Silver Elite                  SE   -> 5
Silver Elite Master           SEM  -> 6
Gold Nova I                   GN1  -> 7
Gold Nova II                  GN2  -> 8
Gold Nova III                 GN3  -> 9
Gold Nova Master              GNM  -> 10
Master Guardian I             MG1  -> 11
Master Guardian II            MG2  -> 12
Master Guardian Elite         MGE  -> 13
Distinguished Master Guardian DMG  -> 14
Legendary Eagle               LE   -> 15
Legendary Eagle Master        LEM  -> 16
Supreme Master First Class    SMFC -> 17
Global Elite                  GE   -> 18

Do we need to account for both the short name and the long name, or can we assume we will only receive the short name or the long name?

@Okx You must handle both cases.

English, 3 bytes Bad

@Mayube that's gold!

@IvankaTodorova Actually it's silver :P

@TheLethalCoder actually it's Global Elite

I contend that "Master Sergeant Shooter Person" should return a value of 999. ;)

@JonathanAllan I don't think it was really necessary to add in the full name of the game, the challenge just uses it as a set up story.

Sure, but naming it hardly impedes (I went to search for what it was, it may save others a few seconds too).

Jelly,  51 49 46  45 bytes
Oḅ4%⁽+Þ%63“¬>ṬṿḄḋḷ<¶Ġþṛṫ9ṡt[`3"G£ḳọċ’b59¤i‘:2

A monadic link accepting a list of characters and returning an integer.
Result is 0-indexed.
Try it online! or see all valid inputs at the test suite.
How?
Oḅ4%⁽+Þ%63“ ... ’b59¤i‘:2 - Main link: list of characters, s  e.g. "Global Elite"
O                         - cast to ordinals                       [71,108,111,98,97,108,32,69,108,105,116,101]
 ḅ4                       - convert from base 4                    448653509 (71 * 4 ^ 15 + 108 * 4 ^ 14 + ... + 116 * 4 + 101 = 448653509)
    ⁽+Þ                   - base 250 compressed number             11771
   %                      - modulo                                 1844 (448653509 = 11771 * 38115 + 1844)
       %63                - modulo 63                              17 (1844 = 63 * 29 + 17)
                     i    - first index (or 0 if not found) in:    33  -----------------------------------------------------------------------+
                    ¤     - nilad followed by link(s) as a nilad:                                                                             |
          “ ... ’         -   base 250 integer = 29327561081972369663135271131767983884313794468054748055733                                  v
                 b59      -   convert to base 59 = [1,4,5,44,6,14,7,23,43,45,16,48,21,49,50,51,13,55,2,53,28,54,10,37,18,36,8,58,31,57,24,47,17,37]
                          -   i.e. all valid results of the hashing except Silver I (40) and S1 (3) in ascending rank order.
                      ‘   - increment                              34
                       :2 - integer divide by 2                    17

(another 45 byter: Oḅ30%⁽EÐ%53“ḷṡ{Żiȧ)ßØẊ×HuÑç%Ɱȧḷ9)×ḍỊ’b53¤i‘:2)

JavaScript (ES6), 164 150 135 bytes
s=>'GE S1|S2|S3|S4|SE|SEMGN1GN2GN3GNMMG1MG2MGEDMGLE LEMSMFC'.search(s[r='replace'](/[a-z ]/g,'')[r]('IV',4)[r](/I+/,a=>a.length))/3||18

(Saved a bunch of bytes thanks to @Craig Ayre and @Steve Bennett.)
Explanation:
s[r='replace'](/[a-z ]/g,'')[r]('IV',4)[r](/I+/,a=>a.length) converts Full names to the SN equivalents.  It doesn't change SNs.
We then simply index into the array of SNs created by split.
Snippet:

f=
s=>'GE S1|S2|S3|S4|SE|SEMGN1GN2GN3GNMMG1MG2MGEDMGLE LEMSMFC'.search(s[r='replace'](/[a-z ]/g,'')[r]('IV',4)[r](/I+/,a=>a.length))/3||18

console.log(f('Silver I'));                      // S1   -> 1
console.log(f('Silver II'));                     // S2   -> 2
console.log(f('Silver III'));                    // S3   -> 3
console.log(f('Silver IV'));                     // S4   -> 4
console.log(f('Silver Elite'));                  // SE   -> 5
console.log(f('Silver Elite Master'));           // SEM  -> 6
console.log(f('Gold Nova I'));                   // GN1  -> 7
console.log(f('Gold Nova II'));                  // GN2  -> 8
console.log(f('Gold Nova III'));                 // GN3  -> 9
console.log(f('Gold Nova Master'));              // GNM  -> 10
console.log(f('Master Guardian I'));             // MG1  -> 11
console.log(f('Master Guardian II'));            // MG2  -> 12
console.log(f('Master Guardian Elite'));         // MGE  -> 13
console.log(f('Distinguished Master Guardian')); // DMG  -> 14
console.log(f('Legendary Eagle'));               // LE   -> 15
console.log(f('Legendary Eagle Master'));        // LEM  -> 16
console.log(f('Supreme Master First Class'));    // SMFC -> 17
console.log(f('Global Elite'));                  // GE   -> 18

console.log(f('S1'));
console.log(f('S2'));
console.log(f('S3'));
console.log(f('S4'));
console.log(f('SE'));
console.log(f('SEM'));
console.log(f('GN1'));
console.log(f('GN2'));
console.log(f('GN3'));
console.log(f('GNM'));
console.log(f('MG1'));
console.log(f('MG2'));
console.log(f('MGE'));
console.log(f('DMG'));
console.log(f('LE'));
console.log(f('LEM'));
console.log(f('SMFC'));
console.log(f('GE'));

Could you remove the parens before indexOf? '...'.split\|`.indexOf`

@CraigAyre, yes, thanks, thought I had already tried that!

You should be able to save a byte by replacing in the other order.  i.e. [r]('I',1)[r]('11',2)[r]('21',3)[r]('1V',4)

No worries! I think you could shave some extra bytes from the numerals: [r]('III',3)[r]('II',2)[r]('I',1) -> [r](/I+/,a=>a.length)

@PunPun1000, I like your suggestion, but CraigAyre's saves more bytes.

Ah. Why didn't I think of this? I thought I'd change SNs to full name with words for each charactet or something.

You can get super close to saving a lot of characters with this kind of approach: 'S1|S2|S3|S4|SE|SEMGN1GN2GN3GNMMG1MG2MGEDMGLE LEMSMFCGE'.search('SEM')/3+1 . Unfortunately, it doesn't work for GE. Sigh.

Ok, this is 135. Haven't thoroughly tested but handles most cases: s=>'GE S1|S2|S3|S4|SE|SEMGN1GN2GN3GNMMG1MG2MGEDMGLE LEMSMFC'.search(s[r='replace'](/[a-z ]/g,'')[r]('IV',4)[r](/I+/,a=>a.length))/3||18

@SteveBennett, your last solution works for all cases.  Thank you for saving me 15 bytes!

Ruby, 120 111 100 99 bytes
->x{x.tr!'a-z ','';x.gsub!(/I.*/){$&.sum%18%11};'

   '[x.sum%36%20+x.ord%4].ord}

Hexdump, since the Stack Exchange software mangles lots of the unprintables in the source code:
00000000: 2d3e 787b 782e 7472 2127 612d 7a20 272c  ->x{x.tr!'a-z ',
00000010: 2727 3b78 2e67 7375 6221 282f 492e 2a2f  '';x.gsub!(/I.*/
00000020: 297b 2426 2e73 756d 2531 3825 3131 7d3b  ){$&.sum%18%11};
00000030: 270e 0f0d 0920 2010 0102 0304 0511 0a20  '....  ........
00000040: 1206 200b 0c20 0708 275b 782e 7375 6d25  .. .. ..'[x.sum%
00000050: 3336 2532 302b 782e 6f72 6425 345d 2e6f  36%20+x.ord%4].o
00000060: 7264 7d                                  rd}

Try it online!
(Note: I can't figure out how to get a carriage return into the "Code" box on TIO, so the TIO version has it replaced with an X and hence outputs 88 instead of 13 for MGE.)
Explanation:
x.tr!'a-z ',''

This deletes all lowercase letters and spaces from the input.
x.gsub!(/I.*/){$&.sum%18%11}

This searches for an I in the string and, if found, replaces it to the end of the string with the result of a black-magic algorithm (found by brute force search) that produces the numeric equivalent of the Roman numeral.
'junk'[more junk].ord

The first section of junk (and the ord) maps the values [7, 8, 9, 10, 11, 16, 21, 22, 3, 13, 18, 19, 2, 0, 1, 6, 12, 15] to the range 1..18 by indexing into the string, which contains the appropriate bytes at their corresponding indices.
The second section of junk maps the values ["S1", "S2", "S3", ...] to the values [7, 8, 9, ...]. The formula was produced by a simple brute force search minimizing the maximum value obtained while ensuring that 18 unique values still exist.

So... string.sum is equivalent to string.bytes.sum? Is there any other quirky sum behavior I should be aware of??? (Also, you need to specify Ruby 2.4)

PHP, 151 Bytes
0-Indexing
Remove all characters that not Uppercase or digit
After that replace the digits with their roman numbers
Search and Output the Key in the Array
<?=array_flip([SI,SII,SIII,SIV,SE,SEM,GNI,GNII,GNIII,GNM,MGI,MGII,MGE,DMG,LE,LEM,SMFC,GE])[strtr(preg_replace("#[^C-V\d]#","",$argn),[_,I,II,III,IV])];

Try it online!
PHP, 158 Bytes
0-Indexing
Remove all characters that not Uppercase
After that replace the roman numbers with their digit
Search and Output the Key in the Array

<?=array_flip([S1,S2,S3,S4,SE,SEM,GN1,GN2,GN3,GNM,MG1,MG2,MGE,DMG,LE,LEM,SMFC,GE])[preg_replace(["#[^C-V]#","#IV#","#III#","#II#","#I#"],["",4,3,2,1],$argn)];

Try it online!
PHP, 295 Bytes
0-Indexing Without Regex
Search and Output the Key of an Array
If more than 4 characters are set in the input take the array with the longer names else take the array with the short names
<?=array_flip(explode(_,$argn[4]?strtr("0I_0II_0III_0IV_03_03 4_1I_1II_1III_14_45I_45II_453_Distinguished 45DMG_2_2 4_Supreme 4 First Class_Global 3",["Silver ","Gold Nova ","Legendary Eagle",Elite,Master," Guardian "]):S1_S2_S3_S4_SE_SEM_GN1_GN2_GN3_GNM_MG1_MG2_MGE_DMG_LE_LEM_SMFC_GE))[$argn];

Try it online!

Retina, 70 bytes
V
3
G.*N.*M|L
55
G.*N
6
M.*G.*E
67
G.*E
99
D
4
E
5
F
88
G
9
\d
$*I
I|M

Try it online! Works by converting specific upper case letter combos into digits and totalling the digits.

Python 3 + Roman, 291 bytes
import roman as r,sys
a=sys.argv
x,y,o=a[1],a[-1],{r:i for i,r in enumerate(["S1","S2","S3","S4","SE","SEM","GN1","GN2","GN3","GNM","MG1","MG2","MGE","DMG","LE","LEM","SMFC","GE"])}
print(o[x if x in o else "".join([n[0] for n in a[1:-1]] + [str(r.fromRoman(y)) if y in "IIIV" else y[0]])])

Non-golfed version:
import roman
from sys import argv

if __name__ == "__main__":
    ranks = ["S1", "S2", "S3", "S4", "SE", "SEM", "GN1", "GN2", "GN3", "GNM",
             "MG1", "MG2", "MGE", "DMG", "LE", "LEM", "SMFC", "GE"]
    output = {rank : i for i, rank in enumerate(ranks)}

    if argv[1] in output:
        print(output[argv[1]])
    else:
        argv[-1] = str(roman.fromRoman(argv[-1])) if argv[-1] in "IIIV" else argv[-1][0]
        print(output["".join([x[0].upper() for x in argv[1:]])])

You can golf the last line to print(o[x if x in o else"".join([n[0] for n in a[1:-1]]+[str(r.fromRoman(y))if y in"IIIV"else y[0]])]).

Also, can't you do y=a.pop(), and then use a[1:] rather than a[1:-1] on the last line?

@Challenger5: First suggestion is great (will work in to my solution tomorrow morning). As for second one, does it actually save any characters? The last line drops 2, but the third line adds 2 I think (since len("a[1:-1]") == len("a.pop()").

Also, you can replace the dictionary comprehension with a call to dict.

That's true, I don't know why I said that.

Also, combining all the assignments won't save you any bytes, so you can split them up for readability.

@Challenger5: I mean, it saves newlines, doesn't it? And since when is readability part of golfing? ;)

It doesn't save bytes unless you have windows-style line endings (in which case, just switch to \n.) If you do that, you can change the assignment to y into *a,y=a, which saves you bytes.

Python 2,  100  96 bytes
lambda s:"F]u^B_&`5qDy,MeN<O$iW'?(d;hHQ2Y:1o%a".find(chr((9*ord(s[0])+ord((s*18)[35]))%92+33))/2

An unnamed function accepting the string s and returning an integer.
Result is 0-indexed.
Try it online!
How?
Takes the 1st and 36th (modulo the length) characters of the input using s[0] and (s*18)[35] respectively, that produces the mapping:
{"Silver I":"Sv", "S1":"S1", "Silver II":"SI", "S2":"S2", "Silver III":"Sr", "S3":"S3", "Silver IV":"SV", "S4":"S4", "Silver Elite":"Se", "SE":"SE", "Silver Elite Master":"St", "SEM":"SM", "Gold Nova I":"Gl", "GN1":"G1", "Gold Nova II":"GI", "GN2":"G2", "Gold Nova III":"G ", "GN3":"G3", "Gold Nova Master":"Gd", "GNM":"GM", "Master Guardian I":"Ma", "MG1":"M1", "Master Guardian II":"MI", "MG2":"M2", "Master Guardian Elite":"Mn", "MGE":"ME", "Distinguished Master Guardian":"Dg", "DMG":"DG", "Legendary Eagle":"Ld", "LE":"LE", "Legendary Eagle Master":"Ll", "LEM":"LM", "Supreme Master First Class":"Sa", "SMFC":"SC", "Global Elite":"Ge", "GE":"GE"}

Converts them to ordinals and converts that from base 9 (ignoring the "base 9 only has 9-digits" restriction) by multiplying the first ordinal by nine and adding it to the second (9*ord(s[0])+ord((s*18)[35])).
Reduces the range of those numbers while maintaining uniqueness by taking the modulo 92 of the result. Adds 33 to make the range fit across printable characters (while avoiding the pesky \ which would require escaping).
Looks up the index of the resulting character in a string, using find and integer divides the result by two with /2 (since every two characters represent a "class" - one for the long name and one for the short name).

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/3.0/


text:
Verbose IP Range Generator
The task is simple, given two IP adresses a and b, output all addresses within that range.

Examples
Example #1:
f(a = 192.168.0.1, b = 192.168.0.4)
    192.168.0.1
    192.168.0.2
    192.168.0.3
    192.168.0.4

Example #2 (TIO will truncate this, use a smaller range when testing):
f (a = 123.0.200.0, b = 124.0.0.0)
    123.0.200.0
    123.0.200.1
    ...            # Omitted pattern
    123.0.200.255
    123.0.201.0
    ...            # Omitted pattern
    123.0.201.255
    ...            # Omitted pattern
    123.0.255.255
    123.1.0.0
    ...            # Omitted pattern
    123.255.255.255
    124.0.0.0

Input and Output

a < b in other words:

Defined Programatically: a[0] < b[0] || (a[0] == b[0] && a[1] < b[1]) || (a[0:1] == b[0:1] && a[2] < b[2]) || (a[0:2] == b[0:2] && a[3] < b[3])
Defined in Words: a will always be lower than b (so you will have to increment the subnet to reach b).
No, you do not have to handle a == b (if you do, kudos).

Output should be in order from "lowest" to "highest" (see examples).
For this challenge, the valid syntax for an IP is: \d{1-3}\.\d{1-3}\.\d{1-3}\.\d{1-3}.
You do not have to handle non-IP address input, if it's unexpected input you may error.
Output may be as an array or as a delimited string (using any whitespace character).

Winning

This is code-golf, lowest byte-count wins.

You have "Omitted Pattern" between e.g. 123.0.200.255 and 123.0.201.0, but aren't they sequential?

@nmjcman101 did that twice, fixed.

Pyth, 22
mj\.jd256}FmivMcd\.256

Try it online.
               cd\.       # split string by "."
             vM           # eval list (convert strings to integers)
            i      256    # convert list of base256 digits to integer
           m          Q   # map the above over implicit input list
         }F               # inclusive range
    jd256                 # convert to list of base256 digits
 j\.                      # join by "."
m                         # map over inclusive range

This inspired a change to Pyth that should make such code shorter in the future. vM will be the default for v when applied to a list.

@isaacg cool - thanks, I'll try to remember that for next time.

Batch, 623 bytes
@echo off
set s=%1.%2
call:c %s:.= %
exit/b
:c
if %1==%5 goto d
call:d %1 %2 %3 %4 %1 255 255 255
set/al=%1+1,u=%5-1
for /l %%i in (%l%,1,%u%)do call:d %%i 0 0 0 %%i 255 255 255
call:d %5 0 0 0 %5 %6 %7 %8
exit/b
:d
if %2==%6 goto e
call:e %1 %2 %3 %4 %1 %2 255 255
set/al=%2+1,u=%6-1
for /l %%j in (%l%,1,%u%)do call:e %1 %%j 0 0 %5 %%j 255 255
call:e %5 %6 0 0 %5 %6 %7 %8
exit/b
:e
if %3==%7 goto f
call:f %1 %2 %3 %4 %1 %2 %3 255
set/al=%3+1,u=%7-1
for /l %%k in (%l%,1,%u%)do call:e %1 %2 %%k 0 %5 %6 %%k 255
call:e %5 %6 %7 0 %5 %6 %7 %8
exit/b
:f
for /l %%l in (%4,1,%8)do echo %1.%2.%3.%%l

Unfortunately Batch's 32-bit arithmetic can't print all IP addresses, so I have to split it up into octets.

Is removing the @echo off an option?  Not that it makes a huge difference.

@DigitalTrauma I guess it's not strictly necessary as the echo always goes to the console and so isn't part of STDOUT but it's very annoying especially on long scripts such as this one.

JavaScript (ES6), 104 bytes
g=s=>s.replace(/(\d+)\.256/,(_,n)=>++n+'.0')
f=(a,b)=>a==b?a:a+`
`+f(g(g(g(g(a+'.256').slice(0,-2)))),b)

This solution replaces the pattern n.256 with n+1.0, and it calls itself recursively until the two parameters are equal.
It appends '.256' to the initial input to get the ball rolling.  slice(0,-2) is then used to remove the trailing '.0'.
Examples:

g=s=>s.replace(/(\d+)\.256/,(_,n)=>++n+'.0')
f=(a,b)=>a==b?a:a+`
`+f(g(g(g(g(a+'.256').slice(0,-2)))),b)

console.log('192.168.0.1 ... 192.168.0.4');
console.log(f('192.168.0.1', '192.168.0.4'));

console.log('123.255.255.0 ... 124.0.3.0');
console.log(f('123.255.255.0', '124.0.3.0'));

console.log('192.1.1.1 ... 192.1.1.1 ... kudos');
console.log(f('192.1.1.1', '192.1.1.1'));

Python 2, 128 bytes
a,b=[reduce(lambda a,b:a<<8|int(b),x.split('.'),0)for x in input()]
while a<=b:print'.'.join(`a>>i&255`for i in[24,16,8,0]);a+=1

Try it online!

PHP, 71 Bytes
Output as string

for($s=ip2long($argv[1]);$s<=ip2long($argv[2]);)echo long2ip($s++)," ";

Try it online!
or
Output as array

print_r(array_map(long2ip,range(ip2long($argv[1]),ip2long($argv[2]))));

Try it online!

Jelly, 18 bytes
ṣ”.V€ḅ⁹µ€r/b⁹j”.$€

Try it online!
The output appears to by a mush of digits and decimals, but is stored internally as a list of strings. Append a Y to the end (+1 byte) to join the strings by newlines.
How it Works
ṣ”.V€ḅ⁹µ€r/b⁹j”.$€ - main link, input is a list of addresses which are strings
       µ€          - for each address string,
ṣ”.                  - split on periods
   V€                - eval each element in the list (convert strings to numbers)
     ḅ⁹              - transform from base 256 to integer (⁹ is 256)
         r/        - take the inclusive range
           b⁹      - convert each element in the range from integer to base 256
             j”.$€ - join each address with periods.

Java (OpenJDK 8), 339 314 282 bytes
Golfed:
long f(String i)throws Exception{return java.nio.ByteBuffer.wrap(java.net.InetAddress.getByName(i).getAddress()).getInt()&(1L<<32)-1;}void g(String[] a)throws Exception{for(long l=f(a[0]),m=255;l<=f(a[1]);)System.out.println(((l>>24)&m)+"."+((l>>16)&m)+"."+((l>>8)&m)+"."+(l++&m));}

Ungolfed:
long ipToLong(String ip) throws Exception {
    return java.nio.ByteBuffer.wrap(java.net.InetAddress.getByName(ip).getAddress()).getInt() & (1L << 32) - 1;
}

void printRange(String[] ips) throws Exception {
    for (long ip = ipToLong(ips[0]), m = 255; ip <= ipToLong(ips[1]);)
        System.out.println(((ip >> 24) & m) + "." + ((ip >> 16) & m) + "." + ((ip >> 8) & m) + "." + (ip++ & m));
}

Try it online!


text:
A+B using C++ language
I'm golfing a program to sum two numbers in C++.
Example:
10 3
13

I found out that this problem can be solved in 54 symbols (without spaces and so on) using C++.
My code (63 symbols):
#include <iostream>
main() {
    int a, b;
    std::cin >> a >> b;
    std::cout << a + b;
}

I have no idea how to make my program shorter. Can you help me, please?

Do the numbers have to come from STDIN?

DJMcMayhem, yes.

I don't think you can beat that if you have to use STDIN.

I saw the 54-symbols result on site, where you can read data only from STDIN or file.

Could you link to where you saw a 54 byte solution? If you have seen a 54 byte solution why can't you use that?

I haven't seen the solution code. I saw only statistics like run time, used memory and length (54 symbols without spaces and etc.)

Your program can not  run according to c++ standard. the function main should have a return type.

I'm voting to close this question as off-topic because it's not a programming puzzle or code golf challenge. It's not a general programming question either, though.

@rahnema1 yes, main function have to be declared with a return type. Some compilers support main() { ... } declaration. I used that in order to make my code shorter.

@CalculatorFeline why do you think that's not a challenge? A goal is to write working A+B program, that will be shorter than mine.

@CalculatorFeline This is a perfectly fine [tag:tips] question, no reason to close it.

48 bytes
How about...
#include<cstdlib>
main(){system("tr \\  +|bc");}

...not using C++?

The call to system runs commands on your shell (<cstdlib> declares system).
tr \\  + executes the command tr, translating spaces to + (so the input34 45 becomes 34+45).
| pipes tr's STDOUT into bc's STDIN.
bc performs equations in STDIN and prints the result to STDOUT.

Can you explain how does it work? I tried to run that program on Linux, but the next error ocured: bc: not found

@eaglemango Well, you have to install bc.

Mind if I edit in an explanation and some links?

@MDXF Fine. (15 chars)


text:
Copodope Gopolopfop
The Language: Oppification
A funny language to speak is created by applying the following process to each word:

Place op after each consonant. So Code becomes Copodope.

Yes, that's it. For the purpose of this challenge, y is always a consonant.
The Challenge: De-oppification
Given an oppified word, return the original word. Input will only contain letters. The first letter may be capitalized. The original word will never be empty and will always contain a vowel.
Test Cases:
Oppified      ->         Original
a                        a
I                        I
itop                     it
opop                     op
Opop                     Op
popopop                  pop
Copopop                  Cop
opopopop                 opop
Kopicopkop               Kick
Asopia                   Asia
soptopopop               stop
hopoopopsop              hoops
hopoopopedop             hooped
ooooohop                 oooooh
aaaopopaaa               aaaopaaa
Popopopsopicoplope       Popsicle
gopaloplopopopinopgop    galloping
aopopbopopopcopopop      aopbopcop

None of your test cases contain a vowel followed by op, so an answer along the lines of replace(/(.)op/, '\1') won't fail any of them. I suggest that you add a word like hoop or looped to the test cases.

@mbomb007 I added some more tricky test cases.

Does the answer only have to work for preoppified inputs or all inputs?

@CalculatorFeline "Given an oppified word"

Actually, all the people I know who speak this for fun agree that you add an "op" only right before a vowel sound. Code => Copode, Benji => Bopenjopi.

Can we add "mopmopmopbopopop" as a test case? :)

@Doorknob I think that approach also works correctly for those test cases, doesn't it?

@BenjiWiebe I'll run that by the person who told me.

WikiHow states "Some Oppish speakers insist on an “opp” after every single consonant, so the word, “flip” would be spelled, “f-opp l-opp i -p-opp.”"

V, 12, 5 bytes
Í.“op

Try it online!
00000000: cd2e 936f 70                             ...op

Saved 7 bytes thanks to @Xnor's realization that since the input must always be opped, we don't have to check for vowels.

Hmm, this seems so hard to beat...

The hex dump: ...op  Is making me laugh way harder than it should

Retina, 9 bytes
(?!\G)op

Try it online!
Instead of checking that the preceding character is a consonant, we just make sure that the current op is not adjacent to either the beginning of the string or the previous match. The only case where we could match an incorrect op is if the original string contained an op (resulting in opop). But in that case we'll just remove the first op instead of the second and the result will be the same.

Wouldn't this give an incorrect answer for an input like loop?

@Leo loop is not a valid input because you can't obtain it from oppifying another word.

@MartinEnder But lopoop (the oppified version of loop) is valid, and doesn't get de-oppified to loop.

@Imus no, the oppified version of loop is lopoopop.

realised my mistake as well shortly after posting it :) was too slow in deleting. Good point.

@MartinEnder you're right. Sadly, it looks like simply replacing .op with the first character, as some answers in other languages do, is shorter (but less interesting, in my opinion)

@Leo Yes, I noticed in the meantime, but I'll leave that to either NoOneIsHere or Doorknob.

Python, 42 bytes
lambda s:re.sub('(.)op',r'\1',s)
import re

Try it online!
If I'm not mistaken, you can just substitute all ?op with ? without caring about vowels. If the original string contains op, then it's oppified to opop, and the replacement returns it to op and no further. This is because the pattern matches for ?op cannot overlap, so only one op is removed.
A non-regex solution is 5 bytes longer.
Python, 47 bytes
f=lambda s:s and s[0]+f(s[1+2*(s[1:3]=='op'):])

Try it online

You can import re after you reference it‽

@Adám Python doesn't evaluate it when the function is defined, only when it's called.

Wow, it's been a while since I've seen anyone use an interrobang. I guess that's a way to golf your comment a little.

@Baldrickk But in bytes, the interrobang has >= bytes than just the string "?!"

Retina, 15 8 bytes
(.)op
$1

Try it online!
-7 bytes thanks to Kevin Cruijssen

You can save 7 bytes by replacing [^aeiou] with .. See @xnor's explanation in his Python answer.

Perl 5, 10 + 1 = 11 bytes
s/.\Kop//g

Try it online!
Run with -p (1 byte penalty); golfing languages might do implicit I/O automatically, but Perl needs an option for it.
When I saw @xnor's answer, I realised it could be improved using a Perl-specific regex feature; s/a\Kb/c/g is equivalent to s/ab/ac/g (in other words, the s/// only replaces the things after the first \K). So here's how it looks in Perl.

Go, 103 92 bytes
Must... compile... Go built-in functions have weird names. :P
import."regexp"
func f(s string)string{return MustCompile("(.)op").ReplaceAllString(s,"$1")}

Try it online!

PHP, 36 bytes
<?=preg_replace("#.\Kop#","",$argn);

Try it online!

How is this supposed to be run?

It fails for the first two test cases. Use preg_replace to fix.

You can save 3 bytes by renaming the variable to any single character, $a for instance

@junkfoodjunkie $argn is a reserved variable which is availbale when PHP is run with the -ROption from the command line

Ah, okay, didn't know that. The online tester doesn't account for it. :-)

Haskell (93 62 61 Bytes)
a(x:'o':'p':r)|notElem x"aeiouAEIOU"=x:a r
a(x:r)=x:a r
a x=x

thanks to @nimi suggestions in comments!

Some tips: as you are using v and o only once, you can inline it. notElem is shorter than not(...elem...). You can replace the && in a guard with a ,. The last case for a can be written as a x=x. No need for () in x:(a r).

... oh, and the test for =="op" can be replaced with a literal pattern match: a(x:'o':'p':r)|notElem x"aeiouAEIOU"=x:a r

Updated. thanks @nimi

One more byte to save: you can omit the space between x and ".

Japt, 9 bytes
r"%Vop"_g

Try it online

JavaScript (ES6), 35 bytes
Add f= at beginning and invoke like f(arg).
s=>s.replace(/([^aeiou])op/gi,"$1")

I am surprised no one posted a JavaScript solution yet....
Test Snippet

let f=
s=>s.replace(/([^aeiou])op/gi,"$1")

console.log("a" + " -> " + f("a"));
console.log("I" + " -> " + f("I"));
console.log("itop" + " -> " + f("itop"));
console.log("opop" + " -> " + f("opop"));
console.log("Opop" + " -> " + f("Opop"));
console.log("popopop" + " -> " + f("popopop"));
console.log("Copopop" + " -> " + f("Copopop"));
console.log("opopopop" + " -> " + f("opopopop"));
console.log("Kopicopkop" + " -> " + f("Kopicopkop"));
console.log("Asopia" + " -> " + f("Asopia"));
console.log("soptopopop" + " -> " + f("soptopopop"));
console.log("hopoopopsop" + " -> " + f("hopoopopsop"));
console.log("hopoopopedop" + " -> " + f("hopoopopedop"));
console.log("ooooohop" + " -> " + f("ooooohop"));
console.log("aaaopopaaa" + " -> " + f("aaaopopaaa"));
console.log("Popopopsopicoplope" + " -> " + f("Popopopsopicoplope"));
console.log("gopaloplopopopinopgop" + " -> " + f("gopaloplopopopinopgop"));
console.log("aopopbopopopcopopop" + " -> " + f("aopopbopopopcopopop"));

C (gcc), 83 bytes
main(c,v)char**v;{for(;*v[1];strchr("aAeEiIoOuU",putchar(*v[1]++))?:printf("op"));}

Try it online!

Java 8, 36 26 bytes
s->s.replaceAll("(.)op","$1")

-10 bytes by replacing [^aeiou] with ., thanks to @xnor's explanation in his Python answer.
Try it here.

sed, 22 bytes
sed -E 's/(.)op/\1/g'

Reads from STDIN until EOF and outputs de-oppified string
Uses same length reduction technique from @xnor's Python answer

Crystal, 39 Bytes
def o(s)s.gsub(/([^aeiou])op/,"\\1")end

How it works
It simply searches for each consonant, followed by the sequence op. If so, replace that sequence only with the consonant found before: ([^aeiou]).
Try it online

Ruby, 34 27 22 + 1 = 23 bytes
-4 bytes thanks to RJHunter.
+1 byte for the -p flag.
$_.gsub!(/(.)op/,'\1')

Try it online!

Using Ruby's -p option will cost a byte but allow your script to start directly with gsub.

///, 18 bytes
/op/.//../o\p//.//

Try it online!
Note that this snippet wants to replace op with a ., but later on there is a replacement defined where op is being put back into the string. That second instruction would have the op replaced by a . (and thus insert a . into the end result), so I've used a \ between the o and p to break the pattern.

APL (Dyalog), 13 bytes
'(.)op'⎕R'\1'

Try it online!
Simply PCRE Replace any character followed by "op" with the character itself.

R, 29 bytes
gsub("(.)op","\\1",scan(,''))

Try it online!
Much like most other solutions here, captures character followed by op, replaces it with character itself.

all_licenses: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/


text:
Print The Input Backward
Just take an input in any way and then print it backward (trailing newlines allowed). For example:
Hello World -> dlroW olleH
Hi -> iH

Yes, it is case sensitive. Shortest code wins

Please do take some time to check for extremely similar challenges. FWIW Jelly 1 byte: Ṛ

As well as being a duplicate, this is underspecified. What may the input contain? What should happen if we get Newlines?

Mathematica, 13 bytes
StringReverse


text:
Generate all halting Smallfuck programs of length n
Your task is to write a program that, given a number n, returns a list of all valid, halting Smallfuck programs of length n, in any order.
Actually, we're using a variation of Smallfuck called F2, which is just Smallfuck with a right-unbounded tape. For the purposes of this challenge, a program that moves left from the start of the tape is considered invalid, as is one with unbalanced brackets.
Scoring
Since solving this for every n is impossible (as it would require you to solve the halting problem), your submission's score will be the lowest n for which it returns an incorrect answer.
Each submission must be, at most, 1000 bytes (though you are encouraged to provide an ungolfed version as well). In the event of a tie, the earlier answer wins.
Test Cases
n = 1:
+ >

n = 2:
++ +> >+ >< >> []

n = 3:
+++ ++> +>+ +>< +>> >++ >+< >+> ><+ ><> >>+ >>< >>> >[] [+] [<] [>] []+ []>

n = 4:
++++ +++> ++>+ ++>< ++>> +>++ +>+< +>+> +><+ +><> +>>+ +>>< +>>> >+++ >++< >++> >+<+ >+<> >+>+ >+>< >+>> ><++ ><+> ><>+ ><>< ><>> >>++ >>+< >>+> >><+ >><< >><> >>>+ >>>< >>>> [][] ++[] +>[] ><[] >>[] [++] [+<] [+>] [<+] [<<] [<>] [>+] [><] [>>] []++ []+> []>+ []>< []>> +[+] +[>] >[+] >[<] >[>] >[]+ >[]< >[]> [+]+ [+]> [<]+ [<]> [>]+ [>]> [[]]

Please inform me if there are any more that I have forgotten to add.

Comments are not for extended discussion; this conversation has been moved to chat.

For n=3 assuming 2-way unbounded tape, we get <[] as well.

@user75200 "For the purposes of this challenge, a program that moves left from the start of the tape is considered invalid."

This challenge is effectively just "write a Smallfuck implementation and find all programs that halt after at least G steps, where G is the largest constant you can fit under 1000 bytes."

Java (OpenJDK 8), Score: ???
This clocks in at 980 bytes, since I had so much to work with I decided to make it a little more readable.  Basically I'm generating all the possible programs for length n and iterating them n^x times for some x.  x is currently 3 but it can be modified arbitrarily to any size, limited only by the limitation of the JVM's precission.  This will work for arbitrarily large input values if x is increased, but I have it set to 3 for tio.
import java.util.*;
public class Main{
    public static void main(String[] args){
        int i = new Scanner(System.in).nextInt();
        int x = 3;
        l:for(int j=0;j<Math.pow(5, i);j++){
            try {
                String s="";
                for(int k=j;s.length()<i;k/=5)
                    s="+<>][".charAt(k%5)+s;
                Stack<Integer>y=new Stack<Integer>();
                Map<Integer,Integer>f=new HashMap<>(),b=new HashMap<>();
                for(int m=0; m<s.length();m++){
                    char c=s.charAt(m);
                    if(c=='[')y.push(m);
                    if(c==']'){int n=y.pop();f.put(n, m);b.put(m, n);}
                }
                if(y.size()>0)
                    continue;
                boolean[] t= new boolean[s.length()];
                int l=0,n=0;
                for(long m=0;l<s.length()&m<Math.pow(i,x);l++,m++){
                    switch(s.charAt(l)){
                    case'+':t[n]=!t[n];break;
                    case'>':n++;break;
                    case'<':n--; if(n < 0)continue l;break;
                    case'[':if(!t[n])l=f.get(l);break;
                    case']':l=b.get(l)-1;break;
                    }
                }
                if(l>=s.length()){
                    System.out.println(s);
                }
            } catch(Exception e){continue;}
        }
    }
}

Try it online!

My guess is that the first program that breaks this will be some sort of counting-in-binary program. I'm not sure exactly how long that would be, though.

I did the same thing in Python, but just had no way of proving anything.  It amused me how difficult the proof felt compared to the actual code.

>>>>>>>>+[[<]+>>>>>>>>+[+<<<<<<<[+>]]<+] is a program that SHOULD do binary counting (I don't know if that part works correctly), is 40 characters long (40*40=1600), and takes 4451 steps to run.  I don't think it's the minimum program that takes longer than n*n steps to run, just an example.

@nmjcman101 Thanks for the input, I've updated the code to do n*n*n but set a variable x to allow it to arbitrarily be increased.  I'm not sure what the score would be at x=3,4,5... and I don't know how I would begin calculating it, so I'm just going to leave it unknown

@PunPun1000 per the halting problem, there is no x such that this algorithm can determine if an arbitrary F2 program halts - indeed, we could then just convert any problem to F2 and solve the halting problem with your algorithm.

@Sanchises I know. That's why I said that you could increase x for arbitrary score, not that there was any x which for which there was infinite score

@PunPun1000 It's impossible to calculate the score as a function of x in general- it turns out that that is equivalent to solving the halting problem :p There is a maximum score that you can provably achieve by increasing x (though my inclination is that this maximum is itself not computable)

Braingolf, Score: 3
1-?"++ +> >+ >< >> []":"+ >"|&@

Start things off nice and easy, hardcodes the correct answer for 1 and 2, outputs + > if n = 1, and ++ +> >+ >< >> [] otherwise

Also add [] for another length-2 testcase.