Posts

Featured post

ruby - Trying to change last to "x"s to 23 -

i have been playing around irb , have string looks this: irb(main):072:0> puts ["[\"4354 5432 5432 xxxxx\", \"6547 6547 8543 xxxxx\", \"2344 6543 6674 xxxxx\", \"2346 6236 7543 xxxxx\", \"1273 5585 5587 xxxxx\"]"] => nil irb(main):073:0> what want gsub last 2 "x" s of each 17 digit combination, 23 . what i've tried far (i've been using rubular): a.gsub(/\d[x]/,"23") <= grabs "x" s i'm close a.gsub(/\w[x{2}]/,"23") <= grabs "x" s grabs two digits each combination. is there easier way i'm not understanding? a.gsub(/\d{4} \d{4} \d{4} xxx\kxx/, '23') \d{4} = 4 digits what \k drop matched far. can use don't replace entire number, still able validate have in desired format.

jquery - Clone last and append item to closest class -

this bare-bones code on page: <div class="list-container"> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> </div> <p><button class="add-list-item">add</button></p> <div class="list-container"> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> <div class="single-list-item"> <button>remove</button> </div> </div> <p><button class="add-list-item">add</button></p> <di...

javascript - Jquery bind event on element fails -

we using jquery 2.1.4 , have written out own javascript class should take care of event. simple "application". taking care of submitting form. before that, processes data. our initial method call on rendering page: owebform.prototype.init = function(){ console.log("init method called"); ... $("#submit_message").on("click", this._submit); console.log($("#submit_message")); ... } owebform.prototype._submit = function(e){ e.preventdefault(); console.log("_submit method called"); ... } once button " #submit_message " clicked, supposed call _submit method of owebform class. when looking @ element within console can see not bound anything, when page loaded. hence code not executed once button clicked. in html have following code: <script type="text/javascript"> var _owebform = new owebform("0bcfwqx23xv02dfaqfujdqyafziic4b07uxkkg1y6lkof7x0px0vjm2tp...

java - What does the following program? -

this question has answer here: is java “pass-by-reference” or “pass-by-value”? 74 answers class ideone { int x; public static void main (string[] args) throws java.lang.exception { ideone i; = new ideone(); i.x = 25; system.out.println(i.x); f(i); system.out.println(i.x); g(i); system.out.println(i.x); } public static void f(ideone j){ j = new ideone(); j.x = 55; // changes new instance of j. not changing actual object } public static void j(ideone j){ j.x = 52; // modifies actual object } } i have doubt in this. in case of j function, modifies actual object. not pass reference? passing object , modifying inside j. but doing samein function f also. passing object , modifying it. not m...

Android SDK: Show one line at a time and proceed with onClick -

i'm new java , android sdk i'm willing learn. want build app take sentence, or generic string , displays 1 line of text, coded. want proceed "next" line clicking button called "proceed". in short offers read little amount of text @ time , proceed b clicking button. this how far i've got: activity_main.xml <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" tools:context=".displaymessageactivity" android:orientation="horizontal" > <textview...

css - Can I use the :after pseudo-element on an input field? -

i trying use :after css pseudo-element on input field, not work. if use span , works ok. <style type="text/css"> .mystyle:after {content:url(smiley.gif);} .mystyle {color:red;} </style> this works (puts smiley after "buu!" , before "some more") <span class="mystyle">buuu!</span>a more this not work - colors somevalue in red, there no smiley. <input class="mystyle" type="text" value="somevalue"> what doing wrong? should use pseudo-selector? note: cannot add span around input , because being generated third-party control. :after , :before not supported in internet explorer 7 , under, on elements. it's not meant used on replaced elements such form elements (inputs) , image elements . in other words it's impossible pure css. however if using jquery can use $(".mystyle").after("add smiley here"); api docs on .after to ...

javascript - How to change format of the phone number? -

at time, format next phone 123-123-1123 i want have next form: (123)456-7890 how can change format whatever shape want? <input class="" type="text" name="primary_phone" id="primary_phone" maxlength="10" placeholder="1234567890"> $("#primary_phone").blur(function() { text = $(this).val().replace(/(\d{3})(\d{3})(\d{4})/, "$1-$2-$3"); $(this).val(text); }); http://jsfiddle.net/xxk3f/2864/ var phone = "123-123-1123"; var newphone = "(" + phone.replace("-", ")"); alert(newphone);