string

Set CSS of words enclosed in double quotes

旧时模样 提交于 2021-02-17 00:55:36
问题 This is a follow up question to my question about Setting the CSS of code if it contains a reserved word. What I am trying to do : If some code has quotes or double quotes, I want to set the color of the font to red and bold. Ex. System.out.println( "Hello world" ); should set "Hello world" to red. What's wrong : Despite my best efforts, I can't seem to get my control statements to work properly (at least I think that's the issue). It sets the first double quote and beyond to red, but when I

Set CSS of words enclosed in double quotes

a 夏天 提交于 2021-02-17 00:54:22
问题 This is a follow up question to my question about Setting the CSS of code if it contains a reserved word. What I am trying to do : If some code has quotes or double quotes, I want to set the color of the font to red and bold. Ex. System.out.println( "Hello world" ); should set "Hello world" to red. What's wrong : Despite my best efforts, I can't seem to get my control statements to work properly (at least I think that's the issue). It sets the first double quote and beyond to red, but when I

Longest consecutive substring of certain character type in python

99封情书 提交于 2021-02-17 00:03:39
问题 Is there a pythonic way to find the length of the longest consecutive substring of a certain character type, for instance the length of the longest consecutive substrings of digits/letters/printable characters? For example in s = "43gfd**54452**jhg4**fddsgf**" The longest digit substring is of length 5, and the longest letter substring is of length 6. 回答1: Regex and max with length as the key: In [12]: s = "43gfd54452jhg4fddsgf" In [13]: max(re.findall(r'\d+', s), key=len) # digits Out[13]:

Manipulating Strings in Assembly (MASM)

前提是你 提交于 2021-02-16 21:59:14
问题 .data source BYTE "Defense mechanism",0 target BYTE SIZEOF source DUP(0) .code main PROC mov esi, OFFSET target mov edi, OFFSET target mov ecx, SIZEOF source L1: mov al,[esi] ; get a character from source mov [edi],al ; store it in the target inc esi ; move to next character inc edi loop L1 In the .data section, I see that source is defined as the string. In the .code section, I see that the memory location of target is stored in the source index. Shouldn't I want the source index ( ESI ) to

Java substring not working

一曲冷凌霜 提交于 2021-02-16 21:26:18
问题 Forgive me, I'm new to Java and have an extremely basic question. I have a string and want a substring of it, for example: String str = "hello"; str.substring(1); System.out.println(str); Instead of getting "ello" I get the original "hello" , any idea why this is? Thanks. 回答1: Strings cannot be changed in Java, so you will need to re-assign the substring as such: str = str.substring(1) as opposed to calling the method by itself. 回答2: Strings in Java are immutable. I believe you want to do

Java substring not working

淺唱寂寞╮ 提交于 2021-02-16 21:26:16
问题 Forgive me, I'm new to Java and have an extremely basic question. I have a string and want a substring of it, for example: String str = "hello"; str.substring(1); System.out.println(str); Instead of getting "ello" I get the original "hello" , any idea why this is? Thanks. 回答1: Strings cannot be changed in Java, so you will need to re-assign the substring as such: str = str.substring(1) as opposed to calling the method by itself. 回答2: Strings in Java are immutable. I believe you want to do

How to use a secondary alphabetical sort on a string list of names?

≯℡__Kan透↙ 提交于 2021-02-16 21:00:58
问题 I'm trying a way that when given a string of names which are first and last names, where names are split by ; and first name split to last name by : -> "Fred:Corwill;Wilfred:Corwill;Barney:Tornbull;Betty:Tornbull;Bjon:Tornbull;Raphael:Corwill;Alfred:Corwill" I want to return a string which is sorted out all the names as uppercase and sorted alphabetically according to the last name and the ones that share the same last name then sort again (secondary sort) between the first names of the

How to use a secondary alphabetical sort on a string list of names?

♀尐吖头ヾ 提交于 2021-02-16 20:59:53
问题 I'm trying a way that when given a string of names which are first and last names, where names are split by ; and first name split to last name by : -> "Fred:Corwill;Wilfred:Corwill;Barney:Tornbull;Betty:Tornbull;Bjon:Tornbull;Raphael:Corwill;Alfred:Corwill" I want to return a string which is sorted out all the names as uppercase and sorted alphabetically according to the last name and the ones that share the same last name then sort again (secondary sort) between the first names of the

How do I split a string on different delimiters, but keeping on the output some of said delimiters? (Tokenize a string)

萝らか妹 提交于 2021-02-16 20:53:51
问题 More specifically I want to split a string on any non alpha-numeric character but in the case that the delimiter is not a white space I want to keept it. That is, to the input: my_string = 'Hey, I\'m 9/11 7-11' I want to get: ['Hey' , ',' , 'I' , "'" , 'm', '9' , '/' , '11', '7' , '-' , '11'] Without no whitespace as a list element. I have tried the following: re.split('([/\'\-_,.;])|\s', my_string) But outputs: ['Hey', ',', '', None, 'I', "'", 'm', None, '9', '/', '11', None, '7', '-', '11']

no matching constructor for initialization of 'string' (aka 'basic_string<char>')

浪尽此生 提交于 2021-02-16 20:31:18
问题 Here is the code: #include <iostream> #include <string> using namespace std; class Foo { public: operator string() const { return n; } string n {"foo"}; }; int main (int argc, char** argv) { string s {Foo{}}; cout << s << endl; return 0; } This code compiles using gcc 4.8.3, but it does not compile using clang 3.5, can someone tell me what's wrong with it? I got an error like this: main.cpp:45:12: error: no matching constructor for initialization of 'string' (aka 'basic_string<char>') string