google analytics – RegEx Filter for merging different URLs (PhpBB)

I have a phpBB forum and would like to summarize the various URLs Google Analytics triggers into 1. Example:

 /forum/viewtopic.php?f=16&t=6457
 /forum/viewtopic.php?t=6457
 /forum/viewtopic.php?f=16&t=6457&start=40

I want them to show everyone

/forum/viewtopic.php?t=6457

I have developed the following regEx filter:

Search and replace
-> Filter Field: Request URI

Search term: /forum/viewtopic.php?f=((0-9)*)&t=(0-9)

Replace string: /forum/viewtopic.php?t=((0-9)+)$

It does not work, I'm not sure what I miss here. Any help?

regex – Optional group is not recorded

I have a huge log file that I want to turn into a spreadsheet. The file looks like this:

********************
SemprePresente1=09/2019
SemprePresente2=987456
Um monte de coisas  
Que não preciso
Opcional=698,00
Mais coisas que não preciso
********************
SemprePresente1=06/2019
SemprePresente2=123658
Um monte de coisas 
Que não preciso
********************
SemprePresente1=09/2019
SemprePresente2=987699
Um monte de coisas
Opcional=9999,00
Mais coisas que não preciso

I can capture the first two groups, but not the optional third, using the following regex pattern:

^(*).+?SemprePresente1=(dd/dddd).+?SemprePresente2=(d{6}).+?((:?Opcional=)(d,)+)?(^*)+

I need something like this:

09/2019;987456;698,00
06/2019;123658;
09/2019;987699;9999,00

However, use the override pattern 1;2;4n In Notepad ++ I get only the following:

09/2019;987456;
06/2019;123658;
09/2019;987699;

Why can not I capture the optional group? Apparently, the pattern matches the entire record without "penetrating" the next one.

Swift: extract string with regex and range

In Swift I have such a string

http://mnc-hdqp.oss-cn-shanghai.aliyuncs.com/user%2Fheat%2Fdefault.jpg?Signature=2BI% 2BauSvy& Expires = 1568682491 & OSSAccessKeyId = LTAIQ8Lif1HHVkXd

Need to extract 2BI%2BauSvy, the value of the key Signature

Here is code: Regex match. Then use range to subtract the key from you.

let key = "Signature"
let signatures = icon.matches(for: "(key)(^&)+")
guard !signatures.isEmpty else{
     return
}
if let range = signatures(0).range(of: "(key)="){
      let signature = String(signatures(0)(range.upperBound...))
      print(signature)
}

How can you implement it conveniently?

regex – The regular expression of GNU Octave may incorrectly number optional groups

Referral groups (parentheses) in a regular expression are executed with $1 $2 $3etc. in GNU Octave and matlab,

But in both GNU Octave and matlab Optional groups are not numbered if they do not match. Is this a bug?

Here is an example:

regexprep("abc","(a)(b)?(c)","$3,$2,$1")
ans = c,b,a
regexprep("ac","(a)(b)?(c)","$3,$2,$1")
ans = ,c,a

expected result of the second variant:

c,,a

here is something similar in sed:

echo -e "abcnac" | sed -E 's/(a)(b)?(c)/3,2,1/'
c,b,a
c,,a

If I look at the regular expression, there are three sets of parentheses, and the third is definitely the one that should match c so that c should come first in the output. However, since the second does not match, c is updated in the backreferences on slot 2.

I think that this is a mistake because the author of the regular expression may not know if a string will contain the optional bit or not. Regardless, the author must decide in advance what to replace by what reference.

It seems to me that sed If you do it correctly, the numbering should match the parentheses in the regular expression, not the way the groups match.

A workaround I'm using now is to be used * Quantifier and ? within the group, instead of making groups optional.

In order to:

regexprep("ac","(a)(b?)(c)","$3,$2,$1")
ans = c,,a

However, this is more complicated with more complex regular expressions, e.g. For example, when searching for a variable with possibly an index:

(w+(((()?d*()))?))

should fit lambda and lambda(1)but also catches lamda() versus

(w+(((()d+())))?)

That's what I really want, but that'll mess up the referencing.

I tested it very fast in Matlab and it seemed to be the same.

regex – Install Package – Stack Overflow

Thank you for your contribution to Stack Overflow in Portuguese!

  • Be sure answer the question, Find out in detail about your solution and share your results.

But avoid

  • Ask for clarification or details about other answers.
  • Make statements based solely on your opinion. point to earlier references or experiences.

For more information, see our tips for writing good answers.

Split chain with regex, whereby the limiter is preserved

I have a string that comes to me in JSON with some data like this

{"name": "AMD", "history": {"2019-09-05": {"open": "31.79", "close": "31.50", "high": "32.05", "low" : "31.12", "volume": "57693493"}, "2019-09-04": {"open": "31.32", "close": "30.95", "high": "31.83", "low" : "30.85", "Volume": "46709780"}, "2019-09-03": {"Open": "30.83", "Close": "30.90", "High": " 31.14 "," Low ":" 30.68 "," Volume ":" 38080254 "}, … etc

With

 string() cotizacion = Regex.Split(cadena_url, @"d{4}-d{2}-d{2}");

I have created an item in the quotation marks array for each day. The problem is that the split eliminates the date and I'm interested in keeping the date and adding it to the array.

I can not add the date to the array.

Many thanks for the help.

Javascript – Regex help for formatting numbers with commas

I have a bunch of numbers that look like 999999999.99999, and I want it to be 999.999.999.99999

The following code works, but I get commas after the comma as follows: 999.999.999.99.999

var numberstring = 999999999.99999;
numberstring.toString().replace(/B(?=(d{3})+(?!d)(W))/g, ",");
console.log(numberstring);

Any help is greatly appreciated! Many thanks.

postgresql – Regex character class: print: in postgres

I'm trying to replicate an Oracle test condition that prevents characters from being printed in Postgres, and I'm at a loss. I think Postgres can handle: print: and: ascii: as synonymys?!?


select REGEXP_REPLACE('bla', '(^(:print:))', '(X)','g') ;
 regexp_replace 
----------------
 bla
(1 row)

select REGEXP_REPLACE('bla'||chr(10)||'bla', '(^(:print:))', '(X)','g') ;
 regexp_replace 
----------------
 bla(X)bla
(1 row)

select REGEXP_REPLACE('Ҕ', '(^(:print:))', '(X)','g') ;
 regexp_replace 
----------------
 (X)
(1 row)

select REGEXP_REPLACE('ñino', '(^(:print:))', '(X)','g') ;
 regexp_replace 
----------------
 (X)ino
(1 row)

Why should Ҕ and ñ be trapped in it?

Every guide is appreciated.

PHP – What's faster for parsing? Regex or built-in DOM?

I want to extract HTML tags and their content from a string. So far I have two options:

  1. Using the integrated regex (preg_match)
  2. Using the built-in DOM object (new DomDocument())

Both work well. But I do not know what's faster, I do not know how to test.

$el = 'li'; // Ex
$match = (); // Reserving for results

/**
 * Regex - extract HTML tag and its content
 * Array map:
 * x(0) = everything
 * x(1) = open tag
 * x(2) = attributes
 * x(3) = content & end tag
 * x(4) = content only
 * 
 * Note for content: including text node + children node
 */
$reg = '/(<'.$el.'(.*?)>)((n*?.*?n*?)|)/';

if (preg_match($reg, $html_str, $match)) { echo 'Moving onward!';} # pure string

It works beautifully! Take a look at my demo of Regex.

$dom = new DomDocument();
$content = mb_convert_encoding(
    get_the_content(null, true), # WordPress func, it gives input str
    'HTML-ENTITIES',
    'UTF-8'
);
$dom->loadHTML($content);

$el = $doc->getElementsByTagName('li'); # DOMNodeList

It works out! But using a large object like DOM seems like wasted, right?

I would like some advice, which is better? Or at least teach me how to test them.