Drupal incorrect node URL - url

My website is using Drupal. On first page I have a list of entries and each entry has own URL.
In some cases, I can't understand when, my links looks like:
/node/1%2C157
Instead of:
/node/1157
In my view I found that my content is displayed by this line:
<?php print render($page['content']); ?>
I need to understand where my content is generated and to fix this problem.
Or maybe I can fix this problem from admin panel ?
( I'm using Pathauto and Path modules to rewrite URL's, on other content is working well but in some nodes I have this problem. I tried to regenerate, to remove and generate again but for this nodes nothing happened ).

The %2C occurs in the url because of comma.Please see if you are creating any url with comma in it.This is possibly the cause of such url.
Here is the list of url encoded characters.
URL Encoded Characters
backspace %08
tab %09
linefeed %0A
creturn %0D
space %20
! %21
" %22
# %23
$ %24
% %25
& %26
' %27
( %28
) %29
* %2A
+ %2B
, %2C
- %2D
. %2E
/ %2F
0 %30
1 %31
2 %32
3 %33
4 %34
5 %35
6 %36
7 %37
8 %38
9 %39
: %3A
; %3B
< %3C
= %3D
> %3E
? %3F
# %40
A %41
B %42
C %43
D %44
E %45
F %46
G %47
H %48
I %49
J %4A
K %4B
L %4C
M %4D
N %4E
O %4F
P %50
Q %51
R %52
S %53
T %54
U %55
V %56
W %57
X %58
Y %59
Z %5A
[ %5B
\ %5C
] %5D
^ %5E
_ %5F
` %60
a %61
b %62
c %63
d %64
e %65
f %66
g %67
h %68
i %69
j %6A
k %6B
l %6C
m %6D
n %6E
o %6F
p %70
q %71
r %72
s %73
t %74
u %75
v %76
w %77
x %78
y %79
z %7A
{ %7B
| %7C
} %7D
~ %7E
¢ %A2
£ %A3
¥ %A5
| %A6
§ %A7
« %AB
¬ %AC
¯ %AD
º %B0
± %B1
ª %B2
, %B4
µ %B5
» %BB
¼ %BC
½ %BD
¿ %BF
À %C0
Á %C1
 %C2
à %C3
Ä %C4
Å %C5
Æ %C6
Ç %C7
È %C8
É %C9
Ê %CA
Ë %CB
Ì %CC
Í %CD
Î %CE
Ï %CF
Ð %D0
Ñ %D1
Ò %D2
Ó %D3
Ô %D4
Õ %D5
Ö %D6
Ø %D8
Ù %D9
Ú %DA
Û %DB
Ü %DC
Ý %DD
Þ %DE
ß %DF
à %E0
á %E1
â %E2
ã %E3
ä %E4
å %E5
æ %E6
ç %E7
è %E8
é %E9
ê %EA
ë %EB
ì %EC
í %ED
î %EE
ï %EF
ð %F0
ñ %F1
ò %F2
ó %F3
ô %F4
õ %F5
ö %F6
÷ %F7
ø %F8
ù %F9
ú %FA
û %FB
ü %FC
ý %FD
þ %FE
ÿ %FF

Related

Merging multiple formulas to eliminate help columns

Consider this table, in which Col A to C are given strings, and Col D to G are array formulas:
A
B
C
D
E
F
G
1
Tese
2
Afetado
REsp 1872759/SP
2020/0103921-2
REsp
Recurso especial
1872759
SP
3
Afetado
REsp 1895255/RS
2020/0237508-4
REsp
Recurso especial
1895255
RS
4
Afetado
REsp 1903883/CE
2020/0288219-1
REsp
Recurso especial
1903883
CE
Col D formula is:
=ARRAYFORMULA(IF(B2:B<>"", REGEXEXTRACT(B2:B,"[^[:space:]]+"),""))
Col E formula is:
=ARRAYFORMULA(IF(D2:D<>""; SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(D2:D, "EREsp", "Embargos em recurso especial"), "AREsp", "Agravo em recurso especial"), "CC", "Conflito de competência"), "REsp", "Recurso especial"), "Pet", "Petição"), "Rcl", "Reclamação"),""))
Col F formula is:
=ARRAYFORMULA(IF(B2:B<>"", REGEXREPLACE(B2:B,"\D+", ""),""))
Finally, Col G formula is:
=ARRAYFORMULA(IF(B2:B<>"", RIGHT(B2:B;2), ""))
All this to help Col H formula return this (note that row in which Col B string is null should return no result):
H
1
2
Recurso especial 1.872.759/SP (2020/0103921-2)
3
Recurso especial 1.895.255/RS (2020/0237508-4)
4
Recurso especial 1.903.883/CE (2020/0288219-1)
Col H formula is:
=ARRAYFORMULA(IF(E2:E<>""; E2:E&" "&TEXT(F2:F; "#,##0")&"/"&G2:G&" ("&TO_TEXT(C2:C)&")"; ""))
Is it possible to build a formula that merges those in Col D to H and achieve the same results?
This is the actual table: link
I can't tell from your example whether you're in a european sheet or not. If so, change all these commas to semicolons:
=ARRAYFORMULA(IF(B2:B="",,E2:E&" "&REPLACE(REPLACE(MID(B2:B,6,100),2,0,"."),6,0,".")&" ("&C2:C&")"))
Solved it!
ARRAYFORMULA(IF(B1:B<>"", SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(REGEXEXTRACT(B1:B,"[^[:space:]]+"), "EREsp", "Embargos em recurso especial"), "AREsp", "Agravo em recurso especial"), "CC", "Conflito de competência"), "REsp", "Recurso especial"), "Pet", "Petição"), "Rcl", "Reclamação")&" "&TEXT(REGEXREPLACE(B1:B,"\D+", ""), "#,##0")&"/"&RIGHT(B1:B,2)&" ("&TO_TEXT(C1:V)&")", ""))
But, if there is a way to simplify this formula, please share!

The R letter in the LR parsing system

I try to understand how the LR parsing work. The L means that the parser reads input text in one direction without backing up; that direction is typically Left to right within each line, and top to bottom across the lines of the full input file.
The R means that the parser produces a Rightmost derivation in reverse. my problem is with R i cant understand what it mean.
just i know right-most derivation for this grammer:
E → E + E | E * E | (E) | id
is as follows:
E → E + E → E+ E * E → E + E * id3 → E + id2 * id3 → id1 + id2 * id3
Thank you.
An LR parser discovers the rightmost derivation backwards. So in your example, the derivations it would discover would be, in order:
stack • input derivation
----------------- ----------
• id1 + id2 * id3 E → id1
E + • id2 * id3 E → id2
E + E * • id3 E → id3
E + E * E • E → E * E
E + E • E → E + E
E •

Racket, ragg: doesn't accept token stream

Using #lang ragg in Racket to create a parser for a simple language. Here is the grammar:
#lang ragg
program : sexpr* start* layout
sexpr : SEXPR
start : WORD WORD "[" WORD* "=" ">" sexpr "]"
layout : elem*
elem : info | text | sexpr
info : "{" text "}"
text : WORD*
And here are the first few tokens:
#(struct:token-struct SEXPR (define a 'something) #f 1 0 #f #f)
#(struct:token-struct WORD run #f 1 22 #f #f)
#(struct:token-struct WORD ram-loop #f 1 26 #f #f)
#(struct:token-struct [ [ #f 1 35 #f #f)
#(struct:token-struct WORD ram #f 1 36 #f #f)
#(struct:token-struct WORD max-ram #f 1 40 #f #f)
#(struct:token-struct = = #f 1 48 #f #f)
#(struct:token-struct > > #f 1 49 #f #f)
(edit) And the input text is: (define a 'something) run ram-loop [ram max-ram => (format \"~a/~a GB RAM\" ram max-ram)] {ram} {fg:#966} {cpu} Some text (leftsep #363)
(edit) And of course.. the error I get when calling (parse) on the token stream:
; Encountered unexpected token #\[ ("[") while parsing #f [line=1, column=35,
; offset=#f] [,bt for context]
It seems obvious that SEXPR WORD WORD [ should be accepted by the grammar. Any idea why it is not?

Ruby - How to remove only 1 whitespace from string

I try to remove 1 whitespace from this string:
m y r e a l n a m e i s d o n a l d d u c k
Expected result:
my real name is donald duck
My code are:
def solve_cipher(input)
input.split('').map { |c| (c.ord - 3).chr }.join(' ') # <- Here I tried everything
end
puts solve_cipher('p| uhdo qdph lv grqdog gxfn')
# => m y r e a l n a m e i s d o n a l d d u c k
I tried everything to solve my problem, example:
input.....join(' ').squeeze(" ").strip # => m y r e a l n a m e...
or
input.....join.gsub(' ','') # => myrealnameisdonaldduck
or
input.....join(' ').lstrip # => m y r e a l n a m e...
and so on...
Well, you could split the string into words first, then split each word into characters. Using the same method you used in your code, it could look like this.
def solve_cipher(input) input.split(' ').map{ |w| w.split('').map { |c| (c.ord - 3).chr}.join('')}.join(' ') end
When joining the characters in the same word, we put no space between them; when joining the words together we put one space between them.
As stated in the question, you are using Rails, so you can also try squish method:
def solve_cipher( input )
input.split(' ').map(&:squish).join(' ')
end
str = "m y r e a l n a m e i s d o n a l d d u c k"
str.gsub(/\s(?!\s)/,'')
#=> "my real name is donald duck"
The regex matches a whitespace character not followed by another whitespace character and replaces the matched characters with empty strings. (?!\s) is a negative lookahead that matches a whitespace.
If more than two spaces may be present between words, first replace three or more spaces with two spaces, as follows.
str = "m y r e a l n a m e i s d o n a l d d u c k"
str.gsub(/\s{3,}/, " ").gsub(/\s(?!\s)/,'')
#=> "my real name is donald duck"
I know that it is not a fancy way of doing it but you could just try to create a new string and have a function traversal(input) with a counter initiated at 0, that would return this new string.
It would go through your input (which is here your string) and if the counter is 0 and it sees a space it just ignores it, increments a counter and go to the next character of the string.
If the counter is different of 0 and it sees a space it just concatenates it to the new string.
And if the counter is different of 0 and it sees something different of a space, it concatenates it to the new string and counter equals 0 again.
The trick is to use a capture group
"m y r e a l n a m e i s d o n a l d d u c k".gsub(/(\s)(.)/, '\2')
=> "my real name is donald duck

Racket - define one character with token-char

I am working on a project for a class and we are tasked with writing a scanner for numbers, symbols, comments, arithmetic operators, parenthesis, and EOF in both Python and Racket. I am working on the racket version and I have written the following line to define one or more character as a symbol:
[(any-char) (token-CHAR (string->character lexeme))]
I have the following line to define on or more digits as a number:
[(:+ digit) (token-NUM (string->number lexeme))]
I am very new to Racket, this is my third program, so I am not exactly sure how to approach this, so any suggestions are greatly appreciated. I have scoured the Racket documentation, but I wasn't able to find what I was looking for.
Thanks!
Here is a minimal getting-started example - heavily commented.
#lang racket
;;; IMPORT
;; Import the lexer tools
(require parser-tools/yacc
parser-tools/lex
(prefix-in : parser-tools/lex-sre) ; names from lex-sre are prefixed with :
; to avoid name collisions
syntax/readerr)
;;; REGULAR EXPRESSIONS
;; Names for regular expressions matching letters and digits.
;; Note that :or are prefixed with a : due to (prefix-in : ...) above
(define-lex-abbrevs
[letter (:or (:/ "a" "z") (:/ #\A #\Z) )]
[digit (:/ #\0 #\9)])
;;; TOKENS
;; Tokens such as numbers (and identifiers and strings) carry a value
;; In the example only the NUMBER token is used, but you may need more.
(define-tokens value-tokens (NUMBER IDENTIFIER STRING))
;; Tokens that don't carry a value.
(define-empty-tokens op-tokens (newline := = < > + - * / ^ EOF))
;;; LEXER
;; Here the lexer (aka the scanner) is defined.
;; The construct lexer-src-pos evaluates to a function which scans an input port
;; returning one position-token at a time.
;; A position token contains besides the actual token also source location information
;; (i.e. you can see where in the file the token was read)
(define lex
(lexer-src-pos
[(eof) ; input: eof of file
'EOF] ; output: the symbol EOF
[(:or #\tab #\space #\newline) ; input: whitespace
(return-without-pos (lex input-port))] ; output: the next token
; (i.e. skip the whitespace)
[#\newline ; input: newline
(token-newline)] ; ouput: a newline-token
; ; note: (token-newline) returns 'newline
[(:or ":=" "+" "-" "*" "/" "^" "<" ">" "=") ; input: an operator
(string->symbol lexeme)] ; output: corresponding symbol
[(:+ digit) ; input: digits
(token-NUMBER (string->number lexeme))])) ; outout: a NUMBER token whose value is
; ; the number
; ; note: (token-value token)
; returns the number
;;; TEST
(define input (open-input-string "123+456"))
(lex input) ; (position-token (token 'NUMBER 123) (position 1 #f #f) (position 4 #f #f))
(lex input) ; (position-token '+ (position 4 #f #f) (position 5 #f #f))
(lex input) ; (position-token (token 'NUMBER 456) (position 5 #f #f) (position 8 #f #f))
(lex input) ; (position-token 'EOF (position 8 #f #f) (position 8 #f #f))
;; Let's make it a little easier to play with the lexer.
(define (string->tokens s)
(port->tokens (open-input-string s)))
(define (port->tokens in)
(define token (lex in))
(if (eq? (position-token-token token) 'EOF)
'()
(cons token (port->tokens in))))
(map position-token-token (string->tokens "123*45/3")) ; strip positions
; Output:
; (list (token 'NUMBER 123)
; '*
; (token 'NUMBER 45)
; '/
; (token 'NUMBER 3))

Resources