Double all the px numbers in a .html file: There is surely something simpler than that.

So I just need to double the numbers before px in a .html file.

Input file (not a correct html, just for test):

7px;21px; 21px; 42pt; 21px; the end 

Expected output:

14px;42px; 42px; 42pt; 42px; the end 

This source code works:

$first_npx_extract_match = '(.*?)(d+)px(.*)' switch -RegEx -File $html_file { $first_npx_extract_match { $output_line = '' do { $output_line = $output_line + ( $matches[1] + ( [int]$matches[2] * 2 ) + 'px' ) $input_line_to_scan = $matches[3] } while ( $input_line_to_scan -match $first_npx_extract_match ) $output_line = $output_line + $input_line_to_scan write-output $output_line } default { write-output $_ } } 

But I am not happy with this, there must be something simpler, right?

submitted by /u/denisrennes
[link] [comments]

Leave a Reply