FAQ Database Discussion Community


Java, cut off array line before charactern nr. X

java,arrays,string,break
So i have massive(i mean massive) array. It has over 500000 lines. Each line starts with some bs that i don't need. What i need is EVERYTHING after 64th symbol(65th symbol is needed). It's the same for every line, but after 64th symbol each line lenght is different. How do...

char* string substract function throws exception

c++,arrays,string,char
I'm working on my own string class called PString, I have this function that finds a specific character, like 6, and now I have this function called substr short fo substract, where I want to substract from 0 to [insertnumber]. the way I'm trying to call this is by doing...

Given length L find the shortest string formed only of as & bs >= L such that adding some character (Either a or b) doesn't produce a new palindrome

string,algorithm,palindrome
Given length L find the shortest string >= L formed only of as & bs such that adding some character (Either a or b) doesn't produce a new palindrome substring (never seen before palindrome) For example for L = 1 there is the string aabbaba, adding "a" to it to...

SumIf with Strings?

string,excel,vlookup
This may be a stupid question, and if it is, I apologise. I have a table in excel: Column a...........Column b 1 property1.......problem x 2 property2.......problemy 3 property3.......problemz 4 property1......problem a I was wondering if I could use sumif (or any similar formula) to add the problems, referring to a...

calling string as variable in python

python,string,variables
I created a class called SignalParam in python containing different properties (frequency, voltage, time, etc) I would like to create many instances of this type vars()['Segment'+str(segment_number)] = SignalParam() this line is working and i can create variables "Segment1", "Segment2", .... My question is: i would like to call those variabes...

search string in textfile [on hold]

c++,c,string,text
Say you have a text file like this all you want from the text is the "size value" but repeats more that thousand time with different value "field_pic_flag : 0 bottom_field_flag : 0 idr_pic_id : 0 Found NAL at offset ,size 28813 !! Found NAL" "field_pic_flag : 0 bottom_field_flag :...

Freeing array of dynamic strings / lines in C

c,string,sorting,malloc,free
I am writing a program that is sorting the lines from the input text file. It does its job, however I get memory leaks using valgrind. #include <stdio.h> #include <stdlib.h> #include <string.h> char* getline(FILE * infile) { int size = 1024; char * line = (char*)malloc(size); int temp; int i=0;...

byte array to string and inverse : recoverded byte array is NOT match to original byte array in Java

java,string,bytearray
I converted a byte array to string as follow, in Java: String str_bytearray = new String(bytearray_original); and then, I recovered original byte array using string, as follow: byte[] bytearray_recovered = str_bytearray.getBytes(); but I wondered when I compared bytearray_original and bytearray_recovered. the result is as follow: [48, 89, 48, 19, 6,...

Android Studio plugin for capture Strings

android,string,android-studio
I'm searching a plugin for Android Studio that help me catch the Strings in my APP, I don't use the recomendations of the Android and make my APP using Strings hardcoded. How do you capture the Strings of codes of automatic way? [I've searched in the google (web) but I...

C++ string.length() Strange Behavior

c++,string,int
I just came across an extremely strange problem. The function I have is simply: int strStr(string haystack, string needle) { for(int i=0; i<=(haystack.length()-needle.length()); i++){ cout<<"i "<<i<<endl; } return 0; } Then if I call strStr("", "a"), although haystack.length()-needle.length()=-1, this will not return 0, you can try it yourself......

java : create string objects using a delimeter

java,string
I have input string array containing value like 1950/00/00;1953/00/00;1958/00/00;1960/00/00;1962/0 What could be the best way to obtain values out of above input which contains 1950/00/00, 1953/00/00, 1958/00/00 , 1960/00/00 and 1962/0 in individual string objects?...

Concatenation of strings array issues in Python: Str(ArrayOfString[1])+“ ”+Str(ArrayOfString[2]) doesn't seem to work

string,python-2.7,concatenation,slice,string-length
Hi I have a problem with a python script, I don't manage to do a concatenation of 2 arrays of strings it returns- SyntaxError: can't assign to function call Here's my script: import os, sys, MySQLdb # connecting to a database db = MySQLdb.connect(host="localhost", user="MyUser", passwd="MyPassword",db="MyDB") cursor = db.cursor() cursor.execute("SELECT...

What is the usage of adding an empty string in a javascript statement

javascript,string,concatenation
I see an empty string ('' or "") used in many JavaScript statements but not sure what does it stand for. e.g. var field = current.condition_field + ''; Can someone please clarify?...

String in Cython functions

python,string,cython
I'd like to do this to pass a string to a Cython code: # test.py s = "Bonjour" myfunc(s) # test.pyx def myfunc(char *mystr): cdef int i for i in range(len(mystr)): # error! len(mystr) is not the length of string print mystr[i] # but the length of the *pointer*, ie...

String manipulation with batch scripting

windows,string,batch-file,space
I need to save the variable in %%c temporarily which comes from a for loop. But when I try to do that, the content changes unexpectedly. Some space characters appear at the end of the string. The content of %%c is a.jpg by the way. echo %%ca REM prints a.jpga...

C++ error: deduced conflicting types for parameter 'T' string vs const char *

c++,string,templates,c++11,char
So, I am writing a simple, templated search function for deque container. Here's the code: template <typename T> void searchInDequeFor(std::deque<T> Deque, T searchValue) { for(const auto & element : Deque) { if(Deque.empty()) { std::cout << "Deque is empty, nothing to search for..." << "\n"; } else if(element==searchValue) { std::cout <<...

How To Check Value Of String

javascript,css,string,numeric
<span id='amount'>0.00000000</span> <a class='button-withdraw' id='tombolco' href='#'>Checkout</a> <script> var amount = document.getElementById("amount").innerHTML; if (amount >= 0.001) { document.GetElementById("tombolco").style = "display:block"; } else { document.GetElementById("tombolco").style = "display:none"; } </script> Why my code doesn't work? What's wrong with it and how to solve it?...

Cannot Properly Print Contents of Vector

c++,arrays,string,vector,segmentation-fault
I have some C++ code where I'm taking input from a user, adding it to a vector splitting the string by delimiter, and for debugging purposes, printing the vector's contents. However, the program only prints the first location of the vector, and then none of the rest. main.cpp #include <cstdlib>...

strip_tags() on MySQLi Query and PHP Function [closed]

php,mysql,string,function,mysqli
I'm trying hard to learn how to create functions, and I don't know what I'm doing wrong here. Could someone explain it to me please? I'm not using strip_tags(), why it's getting me this error? I don't need it to return, I just to need to update database if $xp...

Get the title of a file into a string WITHOUT the extension

php,string
I am trying to get the title of a file into a string WITHOUT the extension. I understand how end() works... but i want the FRONT of the string removed. I can't find something in the PHP manual that directs me into the right direction. ANY help will be appreciated....

C++ & Qt: Random string from an array area

c++,arrays,string,qt,random
In my small Qt application, I want to pick a random string out of an array after I clicked on a button. I've read many threads but nothing works for me. So in my slot there's an array with several strings in it. I also implemented <string>, <time.h> and srand....

How to find if exist an uppercase character in string?

string,axapta,x++,dynamics-ax-2012,uppercase
I need to know if a string is at least one character or more. I need to find the uppercase character . I used this code: str testStr; int flag; testStr = "abdE2" ; flag = strScan(testStr , "ABCDEFGHILMNOPQRSTUVZ" ,flag ,strLen(testStr)); info(strFmt("%1",flag) ); But not work! A problem is that...

More convenient way to work with strings in winapi calls

string,winapi,rust
I'm looking for more convenient way to work with std::String in winapi calls in Rust. Using rust v 0.12.0-nigtly with winapi 0.1.22 and user32-sys 0.1.1 Now I'm using something like this: use winapi; use user32; pub fn get_window_title(handle: i32) -> String { let mut v: Vec<u16> = Vec::new(); v.reserve(255); let...

Replace multiple numbers with other numbers in a string using REGEX c#

c#,regex,string
so I have hundreds of these lines below( i trimmed alot), I want to capture the DEFAULT value and set to 0.99 but only for the lines WITH <Movement display_name="Movement type can be session or system ,independent of type and min and max, I am new to REGEX, this is...

How to call function on every value of String List and change it?

c#,string,foreach
I have a List of Strings and I want to check if they correspond to a specific form. If not i wan't to change that. But I didn't find a nice way to iterate over the elements of the List and change them. I tried to go over list.ForEach(tag =>...

strcmp performance in C

c,string,algorithm,data-structures
int myStrCmp (const char *s1, const char *s2) { const unsigned char *p1 = (const unsigned char *)s1; const unsigned char *p2 = (const unsigned char *)s2; while (*p1 != '\0') { if (*p2 == '\0') return 1; if (*p2 > *p1) return -1; if (*p1 > *p2) return 1;...

Translating a character array into a integer string in C++

c++,arrays,string
I was trying to achieve translating a character array into a integer string and corresponding character to their alphabetical order. For instance: A(a) = 0 , Z(z) = 25. string key_char = argv[1]; string key_num; for (int i = 0; i < key_char.length(); i++){ if (isalpha(key_char[i])){ if (islower(key_char[i])){ key_num[i] =...

Program to reverse a string in C without declaring a char[]

c,string,pointers,char
I need to reverse a given string and display it without using the value At[index] notation , I tried the below program using pointers,but it does not print anything for the reverse string, Please help! int main() { char* name=malloc(256); printf("\nEnter string\n"); scanf("%s",name); printf("\nYou entered%s",name); int i,count; count=0; //find the...

free causing different results from malloc

c,string,malloc,free
Below is a C program i have written to print different combination of characters in a string. This is not an efficient way as this algorithm creats a lot of extra strings. However my question is NOT about how to solve this problem more efficiently. The program works(inefficiently though) and...

How to match words in 2 list against another string of words without sub-string matching in Python?

python,regex,string,loops,twitter
I have 2 lists with keywords in them: slangNames = [Vikes, Demmies, D, MS Contin] riskNames = [enough, pop, final, stress, trade] i also have a dictionary called overallDict, that contains tweets. The key value pairs are {ID: Tweet text) For eg: {1:"Vikes is not enough for me", 2:"Demmies is...

How to extract first letters of dashed separated words in a bash variable?

linux,string,bash,shell,variables
I would like to extract the first letter of dashed separated words value of my bash variable, like this: MY_TEXT=this-is-my-custom-text I would like to create a second variable like this: MY_INITIALS=timct...

Have an if statement look ONLY at the first word in a string [duplicate]

c++,string,if-statement,vector
This question already has an answer here: how to check string start in C++ 9 answers I have a vector composed of strings, some strings have single words, some have multiple words, some have numbers, etc. I have a code that deletes elements of the vector IF the entire...

Python str.format() — passing in list, outputting list

python,string,string-formatting
I haven't used str.format() much before and am wondering how to pass in list values and retrieve a list output with these values passed in. i.e. listex = range(0, 101, 25) baseurl = "https://thisisan{0}example.com".format(*listex) I'd like a list output like ["https://thisisan0example.com", "https://thisisan25example.com", "https://thisisan50example.com", etc etc] but with my current code...

How to avoid the StringIndexOutOfBoundsException if a substring is not in my original String?

java,string,substring,indexof
I have something like: String idCodice = cessionarioCommittente.substring( cessionarioCommittente.indexOf("<IdCodice>") + 10, cessionarioCommittente.indexOf("</IdCodice>")); used to extract the value inside the tag of an XML document represented by the content of the cessionarioCommittente String variable. The problem is that the <IdCodice> tag might not exist in the cessionarioCommittente String. So in this...

Scala: Convert a csv string to Array

arrays,string,scala,split,scala-collections
I tried to convert a scala string to array by splitting it by ,.For example: var string = "a,b,c,d," array = string.split(",") arr: Array[String] = Array(a, b, c, d) But the output I am getting is Array(a, b, c, d), instead of Array(a, b, c, d, ). The last comma...

How to use Split() method in Android

java,android,string,list,split
I have String like this. ex:- String myString = "A=myPage{a1,b1,c1};B=myPage{a2,b2,c2};C=myPage{a3,b3,c3};" I need to put each {_,_,_} part into List. like: If List<String> list = new ArrayList() then, list[0]="a1,b1,c1", list[1]="a2,b2,c2", list[2]="a3,b3,c3" I tried to use split, but I don't know how to apply it into this for getting my result. for...

Split by a comma that is not inside parentheses, skipping anything inside them

java,regex,string,split
I know it might be another topic about regexes, but despite I searched it, I couldn't get the clear answer. So here is my problem- I have a string like this: {1,2,{3,{4},5},{5,6}} I'm removing the most outside parentheses (they are there from input, and I don't need them), so now...

Regex to remove `.` from a sub-string enclosed in square brackets

c#,.net,regex,string,replace
I have this regex in C#: \[.+?\] This regex extracts the sub-strings enclosed between square brackets. But before doing that I want to remove . inside these sub-strings. For example, the string hello,[how are yo.u?]There are [300.2] billion stars in [Milkyw.?ay]. should become hello,[how are you?]There are [3002] billion stars...

Remove Strings with same characters in a String Array

java,arrays,string
I'm facing a problem right now. In one of my program, I need to remove strings with same characters from an Array. For eg. suppose, I have 3 Arrays like, String[] name1 = {"amy", "jose", "jeremy", "alice", "patrick"}; String[] name2 = {"alan", "may", "jeremy", "helen", "alexi"}; String[] name3 = {"adel",...

How create many list as array?

c#,arrays,string,list
I have a problem on creating a set of list in array this is my coding but it's wrong one, any correction for this? List<string>[] item = new List<string>[10](); I want to create 10 list in string named as item but I can't do it and then how can I...

jQuery counter insert commas to break up string

javascript,jquery,string,counter
I have a counter that increments every x seconds, here's my code: var counter=22000000000; if(typeof(localStorage.getItem('counts'))!='object') { counter=parseInt(localStorage.getItem('counts')); } $(".count").html(counter); setInterval(function () { $(".count").html(counter); ++counter; localStorage.setItem('counts',counter); }, 18000); Because the starting number is so high it doesn't read well, see it here: http://jsfiddle.net/vpju4cpr/1/ Ideally instead of outputting 22000000000 I'd like it...

Characters and Strings in Swift

ios,string,swift,unicode,character
Reading the documentation and this answer, I see that I can initialize a Unicode character in either of the following ways: let narrowNonBreakingSpace: Character = "\u{202f}" let narrowNonBreakingSpace = "\u{202f}" As I understand, the second one would actually be a String. And unlike Java, both of them use double quotes...

How to use the contents of a text file(tab delimited format) to rename files in a folder?

c,windows,string,rename
I'm trying to make e-certificates to distribute for one of my college events. I used Photoshop to generate batch certificates with different names and roll nos. Now the files are named core_01Data Set 1.jpg, core_02Data Set 2.jpg, etc. In order to distribute them online, they need to renamed and sorted...

saving base64 decoded string into a zip file

java,string,zip,base64,decode
I am trying to save a base64 decoded string into a zip file using the mentioned code: Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream("/home/wemohamm/Desktop/test.zip"))); out.write(decodedString); out.close(); Here decodedString contains base64 decoded string and I can output it. I am running the code in rhel6 with Java 1.6. When I try...

Javascript Regex to find any number (greater than 0) between two colons

javascript,regex,string
I've tried this: /:(/d+)/:/i and this: /:/[1-9]*/:/i But nothing seems to work. So ideally anything from :1: to :9999999999999999999: would be found ...

Converting strings to arrays c#

c#,arrays,string
I have manipulated a string into the following format: Type___Product___State___Form___Qty____someType___someProduct___someState___someForm___someQty____someOtherType___someOtherProduct... (3 underscores between values, 4 underscores representing a line break if this was a table) What I need to do is Create 5 string arrays (string[] type, string [] product, ...) that pull every 5th value string into it. So...

Typecasting int to char, then search array

c,arrays,string,casting,int
I have a problem with typecasting in C. Let me explain my problem first: I have a 2-dimensional array of integers that is filled with numbers from 0-9 (its a sudoku and 0 means a empty space). Then I have a second array and that is a 3-dimensional char array....

Easiest way to Add lines wrong a .txt file to a list

c#,string,list,streamreader
At the moment I am opening the .txt file twice, once to get the number of all the lines, second to add a line to a list as much as how much lines there are in the .txt file. Is there an easier/better way to do this? This is my...

python splitting string twice

python,string,split,pair
i'm trying to split a string twice with the goal of converting a>b where b contains numbers and is split into multiple x/y pairs a = '{1;5}{2;7}{3;9}{4;8}' b = [[1,5],[2,7],[3,9],[4,8]] my code is currently this... b = a.split('}{') for item in b: item.replace('{','') item.replace('}','') item.split(';') the first split works correctly...

Regex pattern in Python to search for text block inside a file

python,regex,string
Hello I am new to regex and I am trying to compile a regex to match the text block below, there are multiple such text blocks in a file and I would like to move these blocks to another file. Kindly help me! conversion DC_PRESS_1024 { kind = conversionKind rationalFunction;...

How to declare multiple local variables as empty string of String^ in VC++

c++,string,c++-cli
I have many local variables for example : String a1,a2,a3,a4,a5,a6,a7,a8,a9,a10; I need to declare them as empty string in String^ format. If this string is in C#, It is possible to assign them as below :- string Camnr, Klantnr, Ordernr, Bonnr, Volgnr;// and so on. Camnr = Klantnr = Ordernr...

C++11 Allocation Requirement on Strings

c++,string,c++11,memory,standards
I had heard that C++11 was going to require strings to be allocated in contiguous memory. I even thought I saw a stack overflow question on it, but I can't seem to find it. I know that in practice both gcc and Visual Studio do allocate strings contiguously, I'm just...

Memory consumption when chaining string methods

c#,string,immutability,method-chaining
I know that string in C# is an immutable type. Is it true that when you chain string functions, every function instantiates a new string? If it is true, what is the best practice to do too many manipulations on a string using chaining methods?...

SCALA: change the separator in Array

arrays,string,scala,delimiter
I have an Array like this. scala> var x=Array("a","x,y","b") x: Array[String] = Array(a, x,y, b) How do I change the separator comma in array to a :. And finally convert it to string like this. String = "a:x,y:b" My aim is to change the comma(separators only) to other separator(say,:), so...

String parsing with batch scripting

windows,string,parsing,batch-file,xml-parsing
I have a file called pictures.xml and it contains some pictures information like: <ResourcePicture Name="a.jpg"> <GeneratedPicture Name="b.jpg"/> <GeneratedPicture Name="c.jpg"/> </ResourcePicture> <ResourcePicture Name="z1.jpg"> <GeneratedPicture Name="z2.jpg"/> <GeneratedPicture Name="z3.jpg"/> <GeneratedPicture Name="z4.jpg"/> </ResourcePicture> What I want do do is to get each line in for loop and print the names of the pictures. Sample...

If statements depending on order of content in a string

python,string
I would like to create different if statements based on the order of content in a string. string = "ABC Long Short DEF" string = "XYZ Short Long ZYX" So if "Long" comes before "Short" in string do x. Or if "Short" comes before "Long" in string do y. Note...

Split by a word (case insensitive)

python,regex,string,split
If I want to take "hi, my name is foo bar" and split it on "foo", and have that split be case insensitive (split on any of "foO", "FOO", "Foo", etc), what should I do? Keep in mind that although I would like to have the split be case insensitive,...

jQuery / Regex: How to compare string against several substrings

jquery,regex,string,substring,substr
I have a special validation need where I need to check if a string contains ANY out of several substrings like the following list: 12 23 34 45 56 67 78 89 90 01 I am new to jQuery and the only thing I could think of here is the...

Comparing cell contents against string in Excel

string,excel,if-statement,comparison
Following is my table file:*.css file:*.csS file:*.PDF file:*.PDF file:*.ppt file:*.xls file:*.xls file:*.doc file:*.doc file:*.CFM file:*.dot file:*.cfc file:*.CFM file:*.CFC file:*.cfc file:*.DOC I need a formula to populate the H column with True or False if it finds column G in column F (exact case). I used following but nothing seems to...

How to remove diacritics (accents) from a string?

string,dart,diacritics,unaccent
I'm trying to convert some strings that are in Czech, Spanish, French etc. I'd like to take out the accent marks in the letters while keeping the letter. (E.g. convert é to e, č to c, Ž to Z, ñ to n) What is the best way to achieve this?...

.cpp:23: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’

c++,string
Here a basic code I'm trying to run But I'm having trouble with stoi (it's c++) I keep getting error: ‘stoi’ was not declared in this scope I tried atoi and strtol with this error .cpp:23: error: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int atoi(const char*)’...

Combine every 2 elements in an odd-sized array, leaving the last element on its own (Java)

java,arrays,string
Here's an example what I'm trying to do: Let's say I have an array of String with contents {"a","b","c","d","e"} and and second array with contents {"f","g","h","i"} I want code that would return {"ab","cd","e"} on the first array and {"fg","hi"} on the second array. I'm using Java. Below is the code...

C# IEnumerable and string[]

c#,arrays,string,split,ienumerable
i searched for a method to split strings and i found one. Now my problem is that i can´t use the method like it is described. Stackoverflow answer It is going to tell that i cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'string[]'. The provided method is: public static class EnumerableEx...

Matching string inside file and returning result

regex,string,bash,shell,grep
I've got a few peculiar issues with trying to search for a string inside of a .db file. The way I tried was by using grep, which does apparently find the string(s), although this is the output: $ grep "ext" *.db Binary file enormous.db matches There are a couple problems...

Scala string replacement of entire words that comply with a pattern

string,scala,scala-collections,scala-string
In a string, how to replace words that start with a given pattern ? For instance replace each word that starts with "th", with "123", val in = "this is the example, that we think of" val out = "123 is 123 example, 123 we 123 of" Namely how to...

I need to make sure that only certain characters are in a list?

python,regex,string,list,python-2.7
I have this to get input and put it in a list: def start(): move_order=[raw_input("Enter your moves: ").split()] And I only want the characters A, D, S, C, H (it's for a game >_>) to be allowed. I've tried using the regular expressions stuff: if re.match('[ADSCH]+', [move_order]) is False: print...

Decremented value called in the recursion in Haskell

string,function,haskell,recursion,parameters
So, I have this function that aligns the text to the left for a given column width. I have already fixed some of its problems, but I am unable to make it not use the decremented parameter once it is called, but to return to the starting value of n....

Android String if-statement

java,android,string
I have a if-statement in the start of my app if (ready.equals("yes")){ ... } and later on my code I have ready="yes"; but the if statement is never called, why? The ready="yes"; is called from a background thread, is that why? public void DownloadFromUrl(final String fileName) { //this is the...

Regex pass dynamic values with boundry

c#,regex,string,boundary
I'm trying to pass a dynamic value at runtime with a boundary \b to a Regex function. My code is: static void Main(string[] args) { string sent = "Accelerometer, gyro, proximity, compass, barometer, gesture, heart rate"; string match = "gyro"; string bound = @"\b"; if (Regex.IsMatch(sent, @"\bgyro", RegexOptions.IgnoreCase)) { Console.WriteLine("match...

Regex to split string by whitespace OR minus signs in C#

regex,string,split
I have a string with a list of temperatures that can be in the negatives or positives. Some of these temperatures will be separated by a whitespace, while some won't be. i.e.: 19 20 22 -1 -3-4-10 -7 2 10 And I want to split that string by keeping only...

String replace method is not working in android studio

java,android,string
Hey guys I'm not too sure why my word doesn't get replaced in android studio. private Calendar dateTime = Calendar.getInstance(); private SimpleDateFormat dateFormatter = new SimpleDateFormat("dd/MM/yyyy, EEE"); String dateFormat = dateFormatter.format(dateTime.getTime()); Button beginDate = (Button) findViewById(R.id.startDate); beginDate.setText("From " + dateFormat); // Other codes removed for simplicity String beginD = beginDate.getText().toString().replace("From:...

Extracting Substring from File Name

string,awk,substring,extract,cut
I have a list of files with the following file name format: [some unknown amount of characters][_d][yyyymmdd][some unknown amount of characters] I want to extract the substring that contains the date (yyyymmdd) which I know will always be proceeded by "_d". So basically I want to extract the first 8...

How do I isolate the text between 2 delimiters on the left and 7 delimiters on the right in Python?

python,regex,string,split
I have a string: string = ""7807161604","Sat Jan 16 00:00:57 +0000 2010","Global focus begins tonight. Pretty interested to hear more about it.","Madison Alabama","al","17428434","81","51","Sun Nov 16 21:46:24 +0000 2008","243" I only want the text: "Global focus begins tonight. Pretty interested to hear more about it."" which is between the 2nd and...

Display only values containing specific word in array

php,arrays,json,string,if-statement
Right now I am working on a search function for my json decoded results. The code that I got looks like this: <?php foreach($soeg_decoded as $key => $val){ $value = $val["Value"]; $seotitle = $val["SEOTitle"]; $text = $val["Text"]; echo '<tr><td>' . $value . '</td><td>' . $seotitle . '</td><td>' . $text ....

Sql string search

sql,string,search,select
This is my question: Find the capital and the name where the capital includes the name of the country. This is my answer: SELECT name,capital FROM world WHERE capital=concat(name,"NULL") I dont understand what should i do in the "WHERE" part. Should i do capital=concat(name,something?) or IN or LIKE? Can you...

How can I convert an int to a string in C++11 without using to_string or stoi?

c++,string,c++11,gcc
I know it sounds stupid, but I'm using MinGW32 on Windows7, and "to_string was not declared in this scope." It's an actual GCC Bug, and I've followed these instructions and they did not work. So, how can I convert an int to a string in C++11 without using to_string or...

Adding and Subtracting numbers from a String

java,regex,string,delimiter
This program takes in a string and adds up all the integers in it, I have set the delimiter to be "+" surrounded by any amount of white space. It works fine with that but now I want it to work with any negative integers as well, for instance if...

Giving a string variable as a filename in matlab

string,matlab,filenames
I am using the below mentioned code to get the file names of images according to their id's from images_1 text file as strings and use them to read the images from their directory image_count=1; for image_count=1:6 file=fopen('D:\Academics\New folder\CUB_200_2011\images_1.txt','r'); C = textscan(file, '%s'); original_image=imread('D:\Academics\New folder\CUB_200_2011\images\%s','C{1}{2*(image_count)}'); imshow(original_image) end I am able...

bash: How can I assemble the string: `“filename=output_0.csv”`

string,bash,concatenation
I am using a bash script to execute a program. The program must take the following argument. (The program is gnuplot.) gnuplot -e "filename='output_0.csv'" 'plot.p' I need to be able to assemble the following string: "filename='output_0.csv'" My plan is to assemble the string STRING=filename='output_0.csv' and then do the following: gnuplot...

(VBA Excel) Extract Text and related Letter from String and output result

regex,string,excel-vba,character,number-formatting
So the scenario I have is there are letter with a number: Desired Output after Program (Note an underscore is visually used but I need a space: ____________F __G _____E __G__E______F Currently I have written code in the Number and First Letter Column to extract the number and first letter:...

REGEX python find previous string

python,regex,string
I'm trying to find if the last word of the string is followed by a space or a special char, and if yes return the string without this space/special char For example : "do you love dogs ?" ==> return "do you love dogs" "i love my dog " (space...

Concatenating strings using foreach

php,string
I'm trying to make a generated random characters. I'm concatenating the values of $char_type using foreach loop but it doesn't show anything. Here's my code: public function randomizer($range, $type) { $strtester = ''; $char_type = array('alp_sm' => 'abcdefghijklmnopqrstuvwxyz', 'alp_cs' => 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'num' => '0123456789', 'sp' => '[email protected]#$%^&*()'); if(is_array($type)) { foreach($type...

Match part of string with part of other string

php,regex,string,preg-match
I working on a simple search function where I want to match a part of a string with part of another string. Example: The search term is: fruitbag I want to match the product: fruit applebag I want to create something so that the system matches: fruitbag fruit applebag Or...

Convert each letter of string into ascii values - java

java,string,ascii
I want to add two strings and remove duplicate characters of the string then I want to convert each letter of the string into ascii values. After converting, I want to add each letter ascii values and get a total amount of the values.. for ex: ab+ab ab // remove...

Remove quotes to use result as dataset name

r,string
I've got a vector with a long list of dataset names. E.g myvector<-c('ds1','ds2,'ds3') I'd like to use the names ds1..ds3 to write a file, taking the file name from the vector. Like this: write.csv(dataset[i],file=paste(myvector[i],'.csv',sep='') with dataset being d1...ds3, but without quotes. How can I remove the quotes and refer to...

parse a dot seperated string into dictionary variable

python,string,dictionary
I have string values as, "a" "a.b" "b.c.d" How to convert them into python dictionary variables as, a a["b"] b["c"]["d"] The first part of the string (before dot) will become the dictionary name and the rest of the substrings will become the dictionary keys...

Find second to last word in multi-lined string array

java,string
I need to find second to last word in each line (they are divided by space) and find 3 most popular of them and find how many are there? Can you help me in any way? Input example: abcd i asd ffdds abcd ddd ? abcd ffdds asd ddd i...

Create a new loop without quotation marks

python,string,for-loop
I wrote a function on python that should print the sentences below. def write_to_file(matrix, path): f = open(path, "w") f.write('\r\n') for i in range (2,5): item = (bestQuarterRate(matrix, i)) item = (str(item)) print item f.write(item) f.close() The problem is that I get this: ('Highest quarter rate is between', '1/1/15', 'and',...

When trying to include “ in a String, using \” works but the \ is included too

xcode,string,swift,string-formatting
I'm trying to send a string to an Http request using the following code var outStr = "{product_code: \"660825\", quantity: \(qty)}" As I've included the \ character it compiles ok but when I run it the value for outStr is {product_code: \"660825\", quantity: 2} What am I doing wrong and...

Zip with tuples and list

python,string,list,zip,tuples
I need to write a code that will return the characters of two strings as a list of tuples. The code should stop when either one of the strings runs out of characters. I know is a simple code but I cannot get to work where it gives me more...

A beginner questions about printf, java

java,string,printf
I'm learning Java by myself and through tutorials online. Just wondering in a printf statement, what does the different %s, %d, %15, %7, %12.2(and so on...) mean? Couldn't find any explanation anywhere online, so I'm turning to you. ...

Split string in macro

c++,string,split,macros
I've a class name with its namespace, like BasicType::MyType. It's possible to create a macro that split the name and uses only the part after the scope operator (I want to create a MyType object in macro without the first part)? EDIT: I'm using a library with different classes in...

Escape html & non-ascii chars with javascript

javascript,html,string,escaping,non-ascii-chars
OK, so I need to replace all <, & and > plus all non-ascii characters with their html-entity counterparts. I've tried Underscore.string.escapeHTML but that didn't seem to touch the non-ascii chars. For example I need this: <div>föö bär</div> converted into this: &lt;div&gt;f&ouml;&ouml; b&auml;r&lt;/div&gt; Obviously auml and ouml are not enough....

How to Extract Part of a String In JavaScript

javascript,jquery,string,wordpress
I am using a chunk of jQuery code that returns a selected option from a group of image icons. It is integrated into the WordPress WYSIWYG Editor. When I click on the icon this string is sent to the editor: image="'+ $('.icon-option i.selected').attr('class') +'" This code returns: fa fa-heart selected...

How to highlight all the occurrence of a particular string in a web page?

java,html,string,swing
I am writing a swing application. In this application there is a table with some HTTP links. When I click a row a new browser window opens. To this point everything works good. Now I would like to know if it is possible to have all the occurrences of a...

Swift: String contains Character?

string,swift,character
How do I check if a String includes a specific Character? For example: if !emailString.hasCharacter("@") { println("Email must contain at sign.") } ...

Stopping condition on a recursive function - Haskell

string,function,haskell,if-statement,recursion
So, I have this function which aims to align the text on the left without cutting words(only white spaces). However my problem is that I cannot find a stopping condition of the function and it goes infinitely. f n "" = "" --weak condition f n s = if n...

How to remove characters before and including an underscore?

linux,string,bash,unix,awk
In bash scripting what's an efficient way to do the following please? var="fooo_barrrr" What is the best way to remove all characters before and including the '_' so that var becomes "barrrr" please?...

Concatenate appended strings and remove last character

javascript,jquery,string,concat
I have a list that I want to retrieve all items and append them to a paragraph. I am currently successful in doing so but it doesn't append into one string (you need to check the DOM to see it), but several instead. I have tried using .concat() to retrieve...

Create string without repeating the same element jn the string (Matlab)

string,matlab
I have a string "FDFACCFFFBDCGGHBBCFGE" . Could anyone help me to generate a new string with the same order but no element inside repeated twice. Thanks ! The expected output should be like this : "FDACBGHE"...