strings – splitString function effitienty c++

I’ve made a splitString() function which recieves a character and a string and returns a vector<string> containing all the string splitted by a character in the input string:

vector<string> splitString(string input, char separator) {

    size_t pos;
    vector<string> text;

    while (!input.empty()) {

        pos = input.find(separator); //find separator character position

        if (pos == string::npos) {
        text.push_back(input.substr(0, pos));

        input = input.substr(pos + 1);
    return text; //returns a vector with all the strings

Example Input(.csv):


Output would be:

vector<string> contains {name, surname, age}

Is there any efficient way of doing this?

As you can see, the ; was deleted separating the strings.
I was wondering if there is any way of adding an option to NOT delete the separator character including it in the splitted strings.

Escaping strings containing single quotes in PowerShell

How can i replace/escape the single quote in the name cai.o'dowd as its causing errors string is


Currently i’m doing the below and filtering based on userprinciplename

ObjectuserId = (Get-AzureADUser -Filter "UserPrincipalName eq '$($User.LoginName.replace('i:0#.f|membership|',''))'").ObjectId

Any ideas how i can do this in PowerShell? I would also like to check if the field is null before processing it.

Getting errors on SPFx hello world web part in SharePoint 2016 referencing a “strings” file

I am trying to get a hello world web part to work in SharePoint 2016.

I believe the SharePoint server has Feature Pack 2 installed as I see that KB4484255 (version 16.0.4966.100) shows as installed which is the February 2020 update.

enter image description here

My understanding is that I need KB4092459 (version 16.0.474.1000), but that the more recent update above is a cumulative update. However, I’m not certain of that, so maybe that’s where I have things wrong.

My dev environment looks like:

  • node v6.10.3 (using nvm)
  • @microsoft/generator-sharepoint@1.1.0 (globally installed)
  • npm@3.10.10 (globally installed)
  • yo@1.8.5 (globally installed)

I chose no JavaScript framework and just used the code out of the box. The web part works in the workbench. I made no code changes after running the Yeoman generator other than updating the write-manifests.json file to have a URL to my cdnBasePath set to an Azure container URL. I also updated deploy-azure-storage.json, but that doesn’t appear to be working as I manually copied the resulting dist files to the container. The dist files are:

  • 7be2dcde-e1b3-4643-804f-26a2458ca04f.manifest.json
  • hello-world.bundle.js

I did a “bundle –ship” and “package-solution –ship”. And uploaded the sppkg file to my SP2016 app catalog. It showed Yes for Enabled, Valid App Package, and Deployed in the app catalog.

I added the app to my test site. It took several minutes for that to complete. I tried manually running the App Installation Service timer job from Central Admin hoping it would help (I don’t know if it did).

I created a test page and tried to add the web part. I looked for the web part under the “Under Development” category and it was not there. A couple of hours later I deployed a totally different hello world web part (different name and description – created via the Yeoman generator) and then this web part finally showed up in the “Under Development” category. I don’t know if one triggered the other.

Upon adding the web part to the page I get an error:

***Failed to load component “7be2dcde-e1b3-4643-804f-26a2458ca04f” (HelloWorldWebPart). Original error: ***Failed to load URL
for resource ‘helloWorldStrings’ in component
‘7be2dcde-e1b3-4643-804f-26a2458ca04f’ (HelloWorldWebPart). There was
a network problem. This may be a problem with a HTTPS certificate.
Make sure you have the right certificate.

I don’t have a helloworld-webpart-helloworldstrings_en-us_536e65149b0acf4d52c0043073b9fc59.js file in my dist folder. Any idea how I should generate it or otherwise fix this issue?


I have also tried the same thing using the following for my dev environment:

  • node v8.17.0 (using nvm)
  • @microsoft/generator-sharepoint@1.9.1 (globally installed)
  • npm@3.10.10 (globally installed)
  • windows-build-tools@5.2.2 (globally installed)
  • yo@1.8.5 (globally installed)

I don’t know if the build tools are required. I get the same error as my first environment further above looking for a strings file.

google sheets – Counting a cell if another cell has certain strings

To get the value in cell O6 if cell N6 equals “W”, “L” or “BB”, and get zero if cell N6 does not equal one of those values, try this:

=O6 * regexmatch(N6, "^(W|L|BB)$")

The regexmatch() function will return a true/false value, but it gets automatically coerced into 1/0 when an arithmetic operator like * is applied.

strings – Can a Turing machine start on a blank?

Couldn’t find a definitive answer anywhere so asking here. I have a Turing machine and the start state can go straight to the end state without passing through any of the other five states via

Blank -> Blank, R

And one of the questions is

In the best-case, how many steps are required to accept a string?

Is the answer 1 due to this step, or is it just there as a trick question on this worksheet? Thanks in advance.

strings – Censoring emails in Java

I’m working on a simple method that would censor emails (GPDR stuff) so they won’t show the full name of a user, with 1st character, optional dot, 1st character after the dot and whatever is left after the @ to be left uncensored. So, the intent is like this:

Email to be censored:

Desired effect: n***.l*******

I’ve written this:

public static String getCensoredUsername(String username) {
    if (username.contains("@")) {
        char() chars = username.toCharArray();
        for (int i = 1; i < chars.length; i++) {
            boolean isCurrentCharacterADot = chars(i) == '.';
            boolean isPreviousCharacterADot = chars(i - 1) == '.';

            if (chars(i) == '@') {
            if (chars(i) == '.') {
                chars(i) = '.';
            } else if (!isCurrentCharacterADot && !isPreviousCharacterADot) {
                chars(i) = '*';
        return String.valueOf(chars);
    return username;

It feels to me very Java 6. What would make it look better?

mysql – Is using strings as keys for reference to other tables bad in terms of memory usage?

Yes MySql and all other rdms will store the complete email as varchar and reserve space for the number of bytes.

Integer with up to 8 bytes for a big integer will on löy use these bytes, and are so faster when referencing.

In terms of speed you use INTEGER, and consider other like varchar(36) for uuids when the need arises, for example different servers have to save data in the same table.

whith emails a unique and so be indexed for referencing, you should take the extra mile and use Integer if you expect you will have big tables.

strings – C scrabble counter with piping input

I want to start making some command line programs in C, this is a fork of something else I made but is more suitable to this site. My big question is there a better way to pipe commands? I think the way I did it feels improper. I especially feel the string method is a bit hacky.

#include <stdio.h>
#include <unistd.h>
#include <ctype.h>
#include <string.h>
int main(int argc, char *argv())
    char t(32767);
    unsigned int val = 0;
    if (argc == 2)
        memset(t, '', sizeof(t));
        strcpy(t, argv(1));
        read(STDIN_FILENO, t, 32767);
    for (int i = 0; t(i); i++)
        t(i) = tolower(t(i));
    int i;
    for (i = 0; t(i) != ''; i++)
        switch (t(i))
        case 'a':
        case 'e':
        case 'i':
        case 'o':
        case 'u':
        case 'l':
        case 'n':
        case 's':
        case 't':
        case 'r':
            val += 1;
        case 'd':
        case 'g':
            val += 2;
        case 'b':
        case 'c':
        case 'm':
        case 'p':
            val += 3;
        case 'f':
        case 'h':
        case 'v':
        case 'w':
        case 'y':
            val += 4;
        case 'k':
            val += 5;
        case 'j':
        case 'x':
            val += 8;
        case 'q':
        case 'z':
            val += 10;
    printf("%in", val);
    return 0;

I know this is similar to Scrabble word scoring, but I am less interested in the switch but the stdin and the piping.

Strings are not preserved when transforming a shortcode to a Block

In the way to provide a Block to my shortcode plugin, I’m trying to produce the code allowing to transform my shortcode to the Block when the plugin user activates the ‘Convert to Block’ feature to transform its old pages content to blocks.

Unfortunately, after transformation, the original string of the shortcode inner content is not preserved, so what I get in the result of the transformation is not what I get today in the PHP shortcode processing function.

In my index.js function the code is (excerpt:)

registerBlockType( 'music-sheet-viewer/pn-msv', {
                  title: __( 'Music Sheet Viewer' ), 
                  attributes:  {
           content : {
                        type : 'string'
                  transforms: {
                    from: (
                            type: 'shortcode',
                            tag: 'pn_msv',
                            attributes: {
                                content: {
                                    type: 'string',
                                    shortcode: (attributes, data) => {
                                        // data.shortcode.content is the shortcode's inner content
                                        return data.shortcode.content;

In a page, with the classical editor, an example shortcode can be :


When the shortcode is processed, in the PHP function, the ‘content’ string is (PHP log):

(05-Apr-2021 16:36:56 UTC) in process_shortcode=

When I transform my page containing the (pn_msv) shortcode to ‘music-sheet-viewer/pn-msv’ blocks with the ‘Convert to Block’ option, the inner content has been transformed to :

data.shortcode.content=<br />@clef:G-2<br />@keysig:xFCGD<br />@timesig:3/8<br />@data:'6B/{6.E3G},8B-/({6'EGF})({FAG})({GEB})/<br />

thus changing the behaviour according to what was expected.

I have managed to retransform these <br /> to n to restore the original content, but it doesn’t work on more complex cases.
Indeed, I can have such shortcode containing XML tags like:

(pn_msv format="xml")
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "">
<score-partwise version="3.0">
        <score-part id="P1">
     <part id="P1">
        <measure number="1">

And the shortcode content obtained from the block is :

data.shortcode.content=<br /><!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> <br />Music <br />1 <br />0<br /><br /><time><br />4<br />4<br /></time><br /><br />G 2 <br /><br />C<br />4 4<br />whole<br /><br /><br />

Almost every xml tag has been stripped out, so the content is lost..

I’ve tried to add a:
source : ‘html’

to my ‘content’ attribute in my block but it has no effect..

Any idea ?


Conditional Probability of first and second letters in a data set of strings

I have a dataset of strings and I would like to take only the first two letters of each string and find the conditional probability P(Second Letter|First Letter) while only looking at the words of the dataset. I can split the words and make another list with only the first two letters of each word but I’m having difficulty figuring out a way to say for example, all of the two-letter word snippets that start with ‘a’ what is the probability that a,b,c…z will follow as the second letter. I want to do the probability for every letter pair and put it into a 3D histogram where the x-axis will be the first letter chosen, the y-axis will be the second letter and the height will be the probability that that pair occurs within the chosen dataset.

Original dataset {cat,dog,human}
dataset split to only include the first two letters {ca,do,hu}

I’ve been trying to figure out a way to do it and I just can’t seem to get it. I attempted to search to see if anyone has asked a question like mine but I didn’t see anything like it. Any help is thoroughly appreciated.