woocommerce – Printing product variation return array to string conversion error

I’m trying to echo product variation data using Woocommerce plugin.

I have the following code that suppose to parse array using foreach loop:

$variableProduct = wc_get_product(get_the_ID());

$allVariations = $variableProduct->get_available_variations();
foreach ($allVariations as $key => $value) 
{ 
    echo $value;
}

But instead I’m receiving

Notice: Array to string conversion

How to print product variations correctly?

notepad++ – Is there a way to break lines that match a string pattern, but only if that pattern falls between matching strings?

I’m using the code below to break lines that match a pattern:

Find what: ((0-9)) ((A-Z))
Replace with: 1n2

so that …

Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3

… becomes

Super Bowl 3,1:56.2 
Armbro Goal 3,1:54.3

But I have to do it manually because I have tens of thousands of lines and if I use Replace All it will break lines in areas I do not want broken.

Specifically, I want to break lines that match the pattern in areas that lie between “zyxl” and “1st Dam”, but not break any lines with matching patterns between “1st Dam” and “zyxl”

The following code will find the areas where I want lines broken:
(?s)^tzyxl(.|rn)?1st Dam

And this code will find areas where I don’t want code broken:
(?s)^t1st Dam (.|rn)?zyxl

Is there a way, either by combining these methods, or otherwise, to rearrange the text so that …

zyxl
QUEENB BLUE CHIP  
Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3 Grassbed 2,1:59.1  
1st Dam 
RICHESSE OBLIGE Varenne. 13 wins, 2 thru 5. This is her first foal. 
zyxl

VENERATE 
Super Bowl 3,1:56.2 Armbro Goal 3,1:54.3 Grassbed 2,1:59.1  
1st Dam RICHESSE OBLIGE 13 wins, 2 thru 5. This is her first foal. 
Zyxl

… becomes

zyxl
QUEENB BLUE CHIP  
Super Bowl 3,1:56.2
Armbro Goal 3,1:54.3
Grassbed 2,1:59.1  
1st Dam 
RICHESSE OBLIGE Varenne. 13 wins, 2 thru 5. This is her first foal. 
zyxl

VENERATE 
Super Bowl 3,1:56.2
Armbro Goal 3,1:54.3
Grassbed 2,1:59.1  
1st Dam RICHESSE OBLIGE 13 wins, 2 thru 5. This is her first foal. 
zyxl

And yes, “1st Dam” sometimes begins a long line, and sometimes it is the only text on a line, but it always precedes the area that I need untouched by line breaks (followed by “zyxl”).

Thank you in advance for your time and assistance.

sharepoint online – Can you separate multiple values in a single string in @currentfield delimited in some way to make each value a hyperlink

I’m currently using MS’s column formatting JSON to turn a field’s string entry into a URL using the following to automatically make the ticket number entry a clickable hyperlink to our zendesk for the respective ticket number:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "a",
  "txtContent": "@currentField",
  "attributes": {
    "target": "_blank",
    "href": "='https://URLANONYMIZED.zendesk.com/agent/tickets/' + @currentField"
  }

However, if we have multiple tickets for the same issue, it would be nice to be able to do the same for multiple values that are separated by a space, comma, or what have you so that each ticket number would link to it’s respective ticket. Is this possible? Using Office 365 hosted sharepoint if that matters any.

python – programa que reciba un string y un número entero positivo, y cree una nueva cadena dividida con guiones en intervalos marcados por el entero inicial

Entrada
Un string que representa una palabra.
Un número entero positivo mayor a 0.
(Cada entrada en un renglón diferente)

Salida
La palabra recibida como entrada pero separada cada n caracteres con un guión. Si el número recibido es un número negativo o 0, se despliega el mensaje Error.

Ejemplos de ejecución del programa

Paracaidas
3
Par-aca-ida-s

php – How i can perform this function which parse a string

i have wrote this function:

function parser ($src) {
    preg_match_all("/{(.*)}/", $src, $tmp); 
    foreach ($tmp(1) as $vkey => $row) {
        preg_match_all("/((a-z0-9)+)="((wds)+)"/", $row, $col); 
        foreach ($col(0) as $ckey => $param) {
            $row = str_replace($col( 0 )( $ckey ), "", $row );
            $arr($vkey)("attrib")($col( 1 )( $ckey )) = $col( 2 )( $ckey );             
        }
        $arr($vkey)("element") = $row;
    }
    return $arr;
}

Passing this string:

$string = "
    {data:one surname="Rossi" name="Mario"}
    {data:two}
    {data:three text="this is a text"}
"; 

And calling the function parser:

$result = parser( $string );

i have this output:

Array
(
    (0) => Array
        (
            (attrib) => Array
                (
                    (surname) => Rossi
                    (name) => Mario
                )

            (element) => data:one  
        )

    (1) => Array
        (
            (element) => data:two
        )

    (2) => Array
        (
            (attrib) => Array
                (
                    (text) => this is a text
                )

            (element) => data:three 
        )

)

Is possible perform the parser function with a regular expression and have same result?
Thanks!

IMPORTANT: The string is similar to XML format but not is XML format. Here is just for a example

automata – DFA to accept a String containing even number of both A and B, but rejects empty String

I’m going to assume that your DFA has 4 states with the start state also being the singular accepting state.

Add a new (non-accepting) state where the outgoing transitions are a copy from your existing accepting start state. Make that new state the start state.

If my assumption about your existing DFA is correct then this way you should not be able to get into an accepting state with the empty string.

Alter existing ‘Log In’ route so URL includes request_uri as query string

I am trying to alter the existing ‘Log In’ URL so that it points to a certain location and also includes the REQUEST_URI as a query string that is not encoded. How do I do this?

Based on this article, Altering existing routes and adding new routes based on dynamic ones and this SE answer I can change the ‘Log In’ URL so it points to a different location (/login). What I can’t seem to figure out is how to add a query string that isn’t encoded.

This code:

$route->setPath('/login?destination=' . Drupal::request()->server->get('REQUEST_URI'));

Gives me:

/login%3Fdestination%3Dpage2

What I want is:

/login?destination=page2

I have looked into RequestContext::setQueryString and Route::addOptions but can’t seem to get anything to work.

Full code:

<?php
namespace DrupalmyModuleRouting;

use DrupalCoreRoutingRouteSubscriberBase;
use SymfonyComponentRoutingRouteCollection;

/**
* Listens to the dynamic route events.
*/
class RouteSubscriber extends RouteSubscriberBase {

    /**
    * {@inheritdoc}
    */

    protected function alterRoutes(RouteCollection $collection) {
        // Change path '/user/login' to '/login'.
        if ($route = $collection->get('user.login')) {
            //$route->setPath('/login');
            $route->setPath('/login?destination=' . Drupal::request()->server->get('REQUEST_URI'));

        }
        
        // Always deny access to '/user/logout'.
        // Note that the second parameter of setRequirement() is a string.
        if ($route = $collection->get('user.logout')) {
            $route->setRequirement('_access', 'FALSE');
        }
    }
}

python – How to create dictionary in which key and value are taken from string with condition?

I have a string of characters and numbers that I created randomly and replaced punctuations with whitespace. I want to be able to find ‘words’, more specifically, string of characters that are divided by space, that start and end with digits and make those two digits key in a dictionary and the value of this key would be that same word. If a word only starts or ends with digit then I want this digit to be a key and value to be that ‘word’. If a ‘word’ doesn’t start or end with digit I want it to be the value of ‘other’ key.

import random



alfa = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', '.', ',', ':', ';')

st=''.join((random.choice(alfa) for i in range(N)))

st = (item.replace(".", " ") for item in st)
st = (item.replace(",", " ") for item in st)
st = (item.replace(":", " ") for item in st)
st = (item.replace(";", " ") for item in st)

arr = "".join(st)

I’ve tried creating function that preforms the task I want but each time I failed.

"Não é possivel converter de "system.Windows.Forms.TextBox" para string

Novata em C#, estou tentando fazer uma calculadora, porém sempre fica dando esse erro.

public void compute()
    {
        float num;
        switch (count) // cria switch 
        {
            case 1:
                ans = num + float.Parse(textBox1); // erro sempre acontece nessa parte
                textBox1.Text = ans.ToString();
                break;
                
            case 2:
                ans = num - float.Parse(textBox1);
                textBox1.Text = ans.ToString();
                break;
            case 3:
                ans = num * float.Parse(textBox1);
                textBox1.Text = ans.ToString();
                break;

            case 4:
                ans = num / float.Parse(textBox1);
                textBox1.Text = ans.ToString();
                break;

           
            default:
                break;


        }
    }