Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

javascript - Convert "pt" to "px" using regular expression -


in wysiwyg editor, have

<table style="width: 162pt; border-collapse: collapse" border=0 cellspacing=0 cellpadding=0 width=216> 

i can convert to

<table style="width: 162px; border-collapse: collapse" border=0 cellspacing=0 cellpadding=0 width=216> 

using

"wysiwygdata".replace(/pt/g ,"px"); 

is there way change associated value of pt value of px using regex.

162pt might 162*96/72px.

looking help.

you can use regular expression this, feed function string#replace:

s = /* ...the data... */; s = s.replace(/([0-9]+)pt/g, function(match, group0) {      return math.round(parseint(group0, 10) * 96 / 72) + "px"; }); 

live example

when supply function second argument of replace, gets called each match, complete match first argument, , value of capture groups subsequent arguments; return value used replacement. above i'm using capture group capture number, , doing math , returning new string.

you might need or want adjust regex bit make sure fits data (possible spaces between number , units, possibly i flag matches "pt" "pt", etc.), that's fundamental approach.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -